首页 > 其他 > 详细

Controlling GameObjects Using Components

时间:2014-02-01 12:45:50      阅读:449      评论:0      收藏:0      [点我收藏+]

Accessing Components

  The most common case is where a script needs access to other Components attached to the same GameObject.A Component is actually an instance of a class so the first step is to get a reference to the Component instance you want to work with. This is done with theGetComponent function. Typically, you want to assign the Component object to a variable, which is done in C# using the following syntax:

   bubuko.com,布布扣

  Once you have a reference to a Component instance, you can set the values of its properties much as you would in the Inspector:

  bubuko.com,布布扣

  An extra feature that is not available in the Inspector is the possibility of calling functions on Component instances:

  bubuko.com,布布扣
Finding Objects by Name or Tag
  It is always possible to locate GameObjects anywhere in the scene hierarchy as long as you have some information to identify them. Individual objects can be retrieved by name using the GameObject.Find function:
  bubuko.com,布布扣
  An object or a collection of objects can also be located by their tag using the GameObject.FindWithTag and GameObject.FindGameObjectsWithTag functions:
 
  bubuko.com,布布扣
 
   

Controlling GameObjects Using Components

原文:http://www.cnblogs.com/tekkaman/p/3536828.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!