- 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.
推薦閱讀
- PostgreSQL for Data Architects
- AngularJS Web Application Development Blueprints
- 實(shí)用防銹油配方與制備200例
- 算法大爆炸:面試通關(guān)步步為營(yíng)
- Linux網(wǎng)絡(luò)程序設(shè)計(jì):基于龍芯平臺(tái)
- Python Data Analysis(Second Edition)
- C語(yǔ)言程序設(shè)計(jì)學(xué)習(xí)指導(dǎo)與習(xí)題解答
- QGIS By Example
- Python算法從菜鳥到達(dá)人
- Gradle for Android
- Machine Learning in Java
- 零基礎(chǔ)學(xué)Python編程(少兒趣味版)
- C++程序設(shè)計(jì)教程(第2版)
- Mastering jQuery Mobile
- Web前端開發(fā)技術(shù):HTML、CSS、JavaScript