Hi there Unity!
Still getting used to the uGUI system, but it looks like there’s only “On Click” as far as functions go. I want to rotate a character model (Sort of like in WoW where you can view your character’s equipment and rotate him around) by pressing left or right arrows buttons. The problem is, there’s not really a way to detect if the button is down, and setting a bool to true after detecting mouse-down isn’t an option, since the “On Click” function only begins when you release the mouse.
Any help is greatly appreciated.
Thanks!
Just add an event trigger and the Click the add button that appears, should be called something like PointerDown.
A slot will appear for you to drag an object onto all you need is a script with a public function to handle the rotation and set it just as you would with OnClick.
Sorry not got access to Unity ATM so descriptions a bit vague.
EDIT
OnPointerDown and it’ll work for any UI element youu just drag the game object with your script attached to it onto the slot and from the dropdown to the side select YourScriptName → YourPublicFunctionName.
You can also do this with a button click, have the public function set a bool to equal the opposite of itself.
public void BeenClicked()
{
myBool = !myBool;
}
So you button goes from off to on and back with each click, but as you wanted it held OnPointerDown will work for you.
EDIT 2
and this is an event trigger so Add Component Event Trigger not the onclick but event triggers all work pretty much the same as OnClick, they’re just triggered by different actions.