Alex
Alex

Reputation: 43

I can't assign scripts to buttons in UNITY?

I just started exploring Unity and I'm making a game in UNITY 2D. I decided to start with a simple menu screen to get used to UNITY. I made the menu and moved on to programming the buttons.

However when I drag the script (or the game object holding the script) in to the button on click section and try and select my function it does not show up.

My unity window my unity window

Manager in the button on click script. enter image description here

My code in C# (this is my first time using c#) enter image description here

what I want to know is: have I done something wrong; doe unity work differently to how I understand it; is unity doing something weird; how do I fix it.

(appologies for the weird post layout I don't know why it did that).

Upvotes: 0

Views: 2293

Answers (2)

user6873176
user6873176

Reputation:

You need to :

  1. add a semi colon to the end of the line in the Buttons class
  2. Add Buttons Class to the _Manager gameobject in the scene

Upvotes: 1

bolkay
bolkay

Reputation: 1909

Just insert a ; at the end of your code and you should be fine. You should notice that the compiler is complaining about the missing semicolon. Also, make sure to attach your script to the _Manager GameObject.

Upvotes: 1

Related Questions