After hours of work I get a button touch to work just to find out it’s not responsive. I have no idea what is causing this but the button works only 1/2 the time.
EDIT: Since I posted this I transferred the app to a phone and it seems like there is some kind of pointer being emulated. This seems to be the problem. Still can’t find a fix.
public class CameraMovement : MonoBehaviour
{
Text buttontext;
Button Button1;
void Start ()
{
buttontext = GetComponentInChildren<Text>();
Button1 = GetComponent<Button>();
}
void Update()
{
Vector3 Jester = new Vector3(-8, 0, -10);
Vector3 Knight = new Vector3(8, 0, -10);
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
Button1.onClick.AddListener(delegate
{
if (Camera.main.gameObject.transform.position == Jester)
{
Camera.main.gameObject.transform.position = Knight;
buttontext.text = "To Jester";
}
else
{
Camera.main.gameObject.transform.position = Jester;
buttontext.text = "To Knight";
}
}
);
}
}
}