Hi,
How can I achieve the GUI.RepeatButton functionality with the new Unity UI Buttons?
Hi,
How can I achieve the GUI.RepeatButton functionality with the new Unity UI Buttons?
Add a Event UI component that tracks when the pointerUp/Down is true/false to your button:
Component > Event > Event Trigger
Once you are on the component:
Click add
Pointer Down
Pointer Up
Both are PointerEventData
Although not technically a repeat button, you could create a button that toggles a Boolean.
Then in your Update() method execute code conditionally base on your bool value.
Click the button the first time will start the desired behavior and clicking it again will stop it.
private bool isIncrementCounter = false;
void Update ()
{
if (isIncrementCounter)
{
IncrementCounter();
}
}
//Attach this method to your onClick event for your button...
void IncreaseCounterButton_onClick()
{
isIncrementCounter = !isIncrementCounter;
}