Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Button of the UI not showing any functions in the On Click()

Discussion in 'UGUI & TextMesh Pro' started by imposter_syndrom_incarnated, Sep 18, 2020.

  1. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    Hello,
    I just suddenly encountered this problem. No matter what script I assign to this button, it doesn't give me any functions' option.
    What might be the cause of it?
     
  2. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
  3. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    You have to add the script to a Game Object, assign that Game Object to the OnClick() and then you'll see the methods from that script in there. Hope this helps!
     
  4. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    Hii, there is a game object with the associated scrpit that makes the program work already :oops:
     
  5. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    I meant there for the OnClick, I highlighted in red. It shows a script, not a Game Object if I can see it correctly. I tried it here and got the same result as you.
     

    Attached Files:

  6. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    Ohhhh it works as you suggested! Thank youuuu:D:D
     
  7. ldapmonkey

    ldapmonkey

    Joined:
    Sep 28, 2020
    Posts:
    1
    Really? What a "rear-end to elbow" solution. Is there any particular logic to this? Quite honestly, this is such a confusing path that I've searched and searched and only by stupid chance came upon this thread.
     
  8. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    We're in the process of developing UI Toolkit to be a better solution for runtime UI, but this has been the case for UGUI for a long time now, so sorry you had so much trouble finding a solution to your issue! If you check the content in Unity Learn you can probably find many different examples of this.