Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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:
    39
    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:
    39
  3. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    114
    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:
    39
    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:
    114
    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:
    39
    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:
    114
    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.
     
unityunity