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

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.

主站蜘蛛池模板: 大姚县| 新源县| 荆门市| 秦安县| 左云县| 浦县| 永定县| 伊宁县| 牟定县| 内江市| 蒙山县| 大田县| 滨州市| 温州市| 木兰县| 屏东县| 军事| 临沧市| 咸丰县| 长汀县| 五峰| 汝城县| 巴里| 塘沽区| 理塘县| 齐齐哈尔市| 遂昌县| 香格里拉县| 庆云县| 玛沁县| 松阳县| 万州区| 广宗县| 禹城市| 共和县| 三江| 武清区| 益阳市| 大埔县| 色达县| 南雄市|