- Learning C# 7 By Developing Games with Unity 2017(Third Edition)
- Micael DaGra?a Greg Lukosek
- 138字
- 2021-07-02 19:59:35
Adding our script to GameObject
We have created the LearningScript class. Its code is saved in the file in the Project/Scripts folder. To include an instance of this class in our project, we will add it as a component to an empty GameObject.
Let's create a new GameObject. In the menu, navigate to GameObject | Create Empty Child, as shown here:

There are a number of ways of adding our LearningScript component to the GameObject. Let's talk about the simplest one:
- Select your newly created GameObject:

- Drag and drop the Script file from the Project tab to the empty space underneath the Transform component:

We can now see that our LearningScript file has been added as a component to the GameObject. This means that an instance of LearningScript is active and ready to execute code.
推薦閱讀
- Android Wearable Programming
- Deploying Node.js
- Visual FoxPro程序設計教程
- PHP+MySQL網站開發技術項目式教程(第2版)
- 深入理解Java7:核心技術與最佳實踐
- Web Application Development with MEAN
- Mastering Kali Linux for Web Penetration Testing
- 鋒利的SQL(第2版)
- 嚴密系統設計:方法、趨勢與挑戰
- Linux命令行與shell腳本編程大全(第4版)
- Learning Three.js:The JavaScript 3D Library for WebGL
- C語言開發基礎教程(Dev-C++)(第2版)
- Mastering Akka
- 一本書講透Java線程:原理與實踐
- Visualforce Developer’s guide