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

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:

  1. Select your newly created GameObject:
  1. 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.

主站蜘蛛池模板: 裕民县| 巴林右旗| 句容市| 玉门市| 德庆县| 原平市| 郑州市| 广河县| 文登市| 马龙县| 曲阳县| 乐都县| 乌恰县| 盘锦市| 桂平市| 兴海县| 安宁市| 黔南| 搜索| 五常市| 清水河县| 广丰县| 青川县| 临武县| 泰兴市| 交口县| 湾仔区| 岐山县| 威海市| SHOW| 九龙县| 濮阳市| 怀柔区| 随州市| 绥芬河市| 涞源县| 华宁县| 桦川县| 惠州市| 内乡县| 乃东县|