- 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.
推薦閱讀
- 精通Nginx(第2版)
- Android Development with Kotlin
- 正則表達(dá)式經(jīng)典實例(第2版)
- 快速念咒:MySQL入門指南與進(jìn)階實戰(zhàn)
- Unreal Engine 4 Shaders and Effects Cookbook
- Visual C#通用范例開發(fā)金典
- 編程菜鳥學(xué)Python數(shù)據(jù)分析
- Java網(wǎng)絡(luò)編程核心技術(shù)詳解(視頻微課版)
- 從零開始學(xué)Python網(wǎng)絡(luò)爬蟲
- PHP與MySQL權(quán)威指南
- The Statistics and Calculus with Python Workshop
- IBM RUP參考與認(rèn)證指南
- Monitoring Docker
- 軟件開發(fā)中的決策:權(quán)衡與取舍
- C++ Data Structures and Algorithm Design Principles