- Home /
how do i use GUI buttons with a android device(tablet)
I no how to use normal GUI but it apparently doesn't work the same way with the tablet. So all I need to know is how to use gui for android(tablet) and stuff.
here is what im doing in normal GUI
function OnGUI()
{
if (GUI.Button (Rect (100,50,50,20), ">"))
{
transform.Translate(1,0,0);
}
if (GUI.Button (Rect (0,50,50,20), "<"))
{
transform.Translate(-1,0,0);
}
}
Answer by iamthecoolguy11 · Nov 03, 2013 at 07:00 AM
i found how to do it. All you have to do is put this on a gui texture. It only selects the gui texture that it is on tho.
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour
{
void OnMouseDown()
{
Debug.Log("The mouse is down on " + this.name);
Owner.SendMessage(Type);
}
}
Answer by AusAndrew19 · Nov 02, 2013 at 06:10 AM
if(GUI.Button works on Android, But i think i know what your issue is.
you need to use this.
function OnGUI()
{
if (GUI.RepeatButton (Rect (100,50,50,20), ">"))
{
transform.Translate(1,0,0);
}
if (GUI.RepeatButton (Rect (0,50,50,20), "<"))
{
transform.Translate(-1,0,0);
}
}
I Guess your making a platformer or something similar and you want the item to move when your holding the button, So GUI.RepeatButton does just that. Hopefully this is what you are after :)
gui.button does not work on android im asking what dose work tho
GUI.button does work on tablet but it is not recommended to use it. You'd rather use GUITexture and a Rect intersect method.
GUI.Button does work on Android, Check the references, I built a android AP$$anonymous$$ the other day with if(GUI.Button & It Works 100%
can you give a code example as a answer then i can give it a check
when i run the scene on my tablet it wont let me click them tho?