Search Unity

Need Help with Mobile c# script for Gui button hold down

Discussion in 'Scripting' started by DuceCas, Sep 5, 2017.

  1. DuceCas

    DuceCas

    Joined:
    Jun 2, 2017
    Posts:
    13
    Hello guys,

    I am making a game for android now i have a gui button on the sceen with a action,
    I want the preform that action anytime when you press the button or when you hold down the button.

    What is the best way to do it in c# script.

    Thanks,

    Casper
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Assuming you're using the UnityEngine.UI.Button class for your button, take a look at also adding the EventTrigger component to the button: it lets you set up finer-grained notion of touch/release/etc. for that UI element. There's some good examples available on the interwebs of EventTrigger used for the purpose you describe.
     
    DuceCas and JoeStrout like this.