Home > other >  Untity script not attaching to other script
Untity script not attaching to other script

Time:05-30

I am very new to Unity and I'm not sure why this isn't working. enter image description here

I tried to drag and drop the script that I wanted to add but for some reason its not working.

Can someone please explain why?

CodePudding user response:

Does your script exist on an object? From the OOP aspect, if it is not instantiated you should try with that creating a Game Object with your script attached to it.

CodePudding user response:

I don't really know what you have done with the rest of your project but just to make sure, have you place the GameManager onto an object in the scene and then place that object in the gamemanager slot.

More ideas: I have just tested it myself and i will show my exact code to help out with the referencing. I created a c# script named

GameManager

And another named

Click

I then went into the click script and added this line of code

public GameManager gameManager;

Then I made two cubes in the scene and put one script on each and by dragging the cube with the gamemanager script into the gamemanager slot on the cube with the click script.

Let me know how you go. Good Luck.

Thanks. Stan

  • Related