- Home /
Mobile GUI Buttons
I am making a game for IOS, and I want a button to be able to send output to a gameobject. For example, when the UI button is touched, the camera would move up. My button can read inputs from touch, but cannot broadcast them to the gameobject. My script is:
using UnityEngine;
using System.Collections;
public class Test: MonoBehaviour
{
void OnMouseDown()
{
Debug.Log ("Mouse Down");
}
void OnMouseUp()
{
Debug.Log ("Mouse up");
}
}
Should I use global variables? I cannot find anything like this for a button in ios. Thank you for your time.
It should work fine if it's a GUIElement or has a Collider, but it won't work on UI.
Answer by Positive7 · Jul 28, 2015 at 12:54 AM
With UI Button attach this script to the Button then Under OnClick tab press " + " to the object choose " button " and under Function -> test3 -> ClickTest() using UnityEngine; using System.Collections;
public class test3 : MonoBehaviour
{
public void ClickTest()
{
Debug.Log("Clicked !");
}
}
Your answer
Follow this Question
Related Questions
How to Change Menu Button Rollover States with GameObjects 1 Answer
How do I set up a GUITexture as a functional button? 4 Answers
How do you handle a scaledown animation on a UI button? 0 Answers
UI image with button component not tracking mouse correctly 1 Answer
How to change the Source Image of a UI Button when the mouse is on it? 1 Answer