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

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.

主站蜘蛛池模板: 黄骅市| 武夷山市| 连江县| 喀喇沁旗| 双峰县| 奉化市| 宜君县| 钦州市| 迁西县| 鄂伦春自治旗| 都江堰市| 曲麻莱县| 奉化市| 界首市| 安图县| 长治县| 栾城县| 平凉市| 普定县| 盐源县| 墨脱县| 白玉县| 宜阳县| 顺昌县| 常州市| 安仁县| 上饶市| 荔波县| 宝应县| 孝昌县| 保德县| 瑞金市| 宁明县| 陆良县| 仙居县| 洪江市| 朔州市| 亳州市| 商丘市| 苍溪县| 鄂州市|