Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Two Function on a single Button

Discussion in 'Unity UI & TextMesh Pro' started by kingmujo, Aug 13, 2017 at 4:22 AM.

  1. kingmujo


    Aug 7, 2017
    Hi Guys!

    is there a possibility (if yes how?:p) to put two functions in a single ui button ?
    for example i have two animations: anim1: standing still table, anim2: rotating table.

    i want a "start/stop" ui button...

    at beginning the table stands still(cuz of anim1) and the button says "start"...
    when i click the button it calls my anim2, the table starts rotating and the button says now "stop"...
    when i click the button again it calls my anim1, the table stops rotating and the button says now "start"...
    and so on ...

    how can i solve this problem ?
  2. SimonDarksideJ


    Jul 3, 2012
    It's not really a "problem" per-se
    You just need a behaviour script linked to the click event of the button. In that script you have a bool value that is changed when you click, then based on that bool, you change the view / action of the button.

    I did some similar things with the new Cooldown button in the UIExtensions project (link in signature) which should help. I'll see about adding this style of control to the project as well.