Just like Input.GetKey()
for keyboard is there any way to take continuous input from UI button event trigger OnPointerDown
? Because for movement controls with animation its giving very weird output? I have to click it again and again which I don't want to!
And if answer is manually tracking then how to do that ?
You can do this with the OnPointerDown
and OnPointerUp
functions then use a simple boolean variable to keep the states. You can then check of the press in the Update function.
public class YourCode : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
bool pointerDown = false;
public void OnPointerDown(PointerEventData eventData)
{
pointerDown = true;
}
public void OnPointerUp(PointerEventData eventData)
{
pointerDown = false;
}
void Update()
{
if (pointerDown)
{
//Your Code
}
}
}