I have a right, left and up button on the screen (its a 2D game). I am trying to figure out how to write a script so that when the user clicks the buttons, they receive the input and either move the player right left or up. I have watched some tutorials on youtube but they are from a couple of years ago and are out of date and don’t work for me. Could anyone send me a script or tell me how to code it (c#) so that it can recognise the touch input?
Touch response for UI buttons is the same as for mouse input. Simply put a handler in place for the “On Click” event of the button.
1 Like
i am trying to make a homescreen, i am new to unity, so can you post an example script as how to do an on click function?
I’d attach an “Event System” to the button. That way you can get pressed and hold in addition to released (OnClick).