官术网_书友最值得收藏!

Watching for possible gotchas while creating script files in Unity

Notice line 4 in the following screenshot:

public class LearningScript : MonoBehaviour 

The class name LearningScript is the same as the filename LearningScript.cs. This is a requirement. You probably don't know what a class is yet, but that's okay. Just remember that the filename and the class name must be the same.

When you create a C# script file in Unity, the filename in the Project tab is in Edit mode, ready to be changed. Please rename it right then and there. If you rename the script later, the filename and the class name won't match. The filename would change, but line 4 will be this:

public class NewBehaviourScript : MonoBehaviour 

This can easily be fixed in MonoDevelop by changing NewBehaviourScript in line 4 to the same name as the filename, but it's much simpler to do the renaming in Unity immediately.

主站蜘蛛池模板: 江口县| 佛教| 巢湖市| 济源市| 大厂| 定边县| 渝北区| 屏东县| 淮阳县| 黎平县| 义乌市| 平凉市| 拜泉县| 郯城县| 石柱| 会昌县| 珠海市| 叶城县| 保德县| 卓尼县| 阜城县| 海伦市| 梁山县| 蓝山县| 松溪县| 邵阳县| 临湘市| 郎溪县| 福安市| 密山市| 哈密市| 麻栗坡县| 丘北县| 宾川县| 林州市| 布尔津县| 曲阳县| 苍南县| 金沙县| 克山县| 邹平县|