Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Resolved Using one of the button events

Discussion in 'Scripting' started by Stormchaser36, Apr 26, 2021.

  1. Stormchaser36

    Stormchaser36

    Joined:
    Mar 5, 2021
    Posts:
    23
    Hello! I have a problem with UI buttons. I've created button and put on it 2 functions in OnClick() array list. I need to write in code when my character is in trigger, button can execute only 1 function, others must be locked, but I don't know how to get this array list and lock other functions in C#. Please, help me.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,191
    Don't worry about doing that. Instead, just use a bool. When a player enters a trigger, set the bool to true. Then in the method you don't want to execute, check if the bool is true and if it is, return or skip the code. If it's false, execute the code as normal.
     
    GroZZleR likes this.