Search Unity

OnClick end help

Discussion in 'UGUI & TextMesh Pro' started by will_brett, Jul 9, 2015.

  1. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Hey there,

    So I want to use a UGUI button for an accelerator trigger.

    So I want to be able to hold down the button to accelerate and for it to stop accelerating when the button is no longer clicked. What would be the best way to achieve this?

    I was thinking of setting a bool to true when button is clicked and then set bool to false when button is let go however not sure this is the best way or how to do it so any help would be really appreciated.

    Thanks
     
  2. coopoot

    coopoot

    Joined:
    Oct 30, 2014
    Posts:
    2
    cada Grupo de botoes tem referencia a um else
    exemplo

    void onCommand(string bt){
    if(bt.Equals("Botão1")){
    condição aqui
    }else{
    outra condição
    }
    }
    void onCommand2(string bt2){
    if(bt2.Equals("Botão2")){
    condição aqui
    }else{
    outra condição
    }
    }

    ai tem dois metodos onde os dois elses podem fazer algo diferente