Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question I am trying to get a UI button pressed property to activate when an input button is pressed,

Discussion in 'Scripting' started by justinmed, May 21, 2024.

  1. justinmed

    justinmed

    Joined:
    Dec 19, 2021
    Posts:
    106
    Hi, I am trying to get a UI button pressed property to activate when an input button is pressed, and I have the invoke command down and it works, how can I achieve the pressed color property in the same way?

    I tried this, and the invoke part works, but the pressed color will not show.

    Code (CSharp):
    1. if (note.noteNumber == 60)
    2.                 {
    3.  
    4.                     A1Button.onClick.Invoke();
    5.                     A1Button.interactable.HasProperty("Pressed");
    6.                 }
     
  2. justinmed

    justinmed

    Joined:
    Dec 19, 2021
    Posts:
    106
    So I got it to work with this:

    Code (CSharp):
    1.  
    2. A1Button.onClick.Invoke();
    3. ExecuteEvents.Execute(A1Button.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.submitHandler);