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

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.

主站蜘蛛池模板: 镇江市| 洛阳市| 堆龙德庆县| 临湘市| 柳州市| 松原市| 交口县| 靖宇县| 高台县| 靖西县| 通道| 武城县| 西贡区| 夏邑县| 益阳市| 罗田县| 双江| 三门峡市| 钟山县| 馆陶县| 乌兰浩特市| 云林县| 裕民县| 永仁县| 浪卡子县| 格尔木市| 长汀县| 赣州市| 高唐县| 兴隆县| 轮台县| 清涧县| 徐闻县| 慈溪市| 阿瓦提县| 天等县| 汪清县| 晋城| 天水市| 垣曲县| 萨嘎县|