Common mistakes in Unity: Unable to add scripts

In some cases, students who have just entered Unity hope to be able to put their own code into their own game objects after completing all the environment settings. However, at this time, an error message appears that they cannot add scripts: as follows:

 "" is the name of the file. The solution to this situation is very simple. What we need to check is whether the corresponding class name in the code is consistent with the name of the game object we want to carry. 

 

By default, it will be named NewBehaviourScript. At this time, we only need to change the name to the name of our piggyback target.

 

 At the same time, it should be noted that the name of your script must also be consistent with the name of the mounting target, otherwise the error that appears at the beginning of the article will appear.

Then you can install the script normally and continue your journey of learning Unity.

Guess you like

Origin blog.csdn.net/BJCRK/article/details/131786435