- Home /
Question by
matta9001 · Oct 11, 2014 at 01:49 AM ·
javascriptui4.6
unity 4.6 button functions?
The button has a default function of OnClick(). I wanted to have a boolean that was true while the person has their finger on the button, and have it false while they are not. There is no function where you lift your finger, and there is no function to get a status. Is unity 4.6 just limited or am i missing something do you know how to do this?
Comment
Best Answer
Answer by orb · Oct 11, 2014 at 03:58 AM
The methods you're looking for are OnPointerDown() and OnPointerUp(). Example:
using UnityEngine;
using UnityEngine.EventSystems;
public class ClickyStuff : MonoBehaviour, IPointerDownHandler
{
public void OnPointerDown(PointerEventData data)
{
// Set your variable here
}
}