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:

  

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

  

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

  
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:
  
  An object or a collection of objects can also be located by their tag using the GameObject.FindWithTag and GameObject.FindGameObjectsWithTag functions:
 
  
 
   

Controlling GameObjects Using Components的更多相关文章

  1. Unity3D用户手册

    Unity Manual 用户手册 Welcome to Unity. 欢迎使用Unity. Unity is made to empower users to create the best int ...

  2. 从Unity引擎过度到Unreal4引擎(最终版)

    原文地址:http://demo.netfoucs.com/u011707076/article/details/44036839 前言 寒假回家到现在已经有十多天了,这些天回家不是睡就是吃....哎 ...

  3. Unity3D开发之查找面板上某个脚本(包括Missing)

    原地址:http://blog.csdn.net/lihandsome/article/details/24265411 有时候我们需要知道某个脚本在场景上面哪里用到,或者那个脚本被删除了但又没有把相 ...

  4. Unity 4.3 2D 教程:新手上路

    这篇文章译自 Christopher LaPollo 先生的 Unity 4.3 2D 教程的第一部分 Unity 4.3 2D Tutorial: Getting Started 感谢这套优秀教程的 ...

  5. Unity 5 Game Optimization (Chris Dickinson 著)

    1. Detecting Performance Issues 2. Scripting Strategies 3. The Benefits of Batching 4. Kickstart You ...

  6. Unity3D开发之查找面板上某个脚本(包含Missing)

    有时候我们须要知道某个脚本在场景上面哪里用到,或者那个脚本被删除了但又没有把相关游戏场景的关联东西删掉,那样我们就要一个脚本来查找一下了: PS:以下两个脚本都要放到assets/Editor以下哦. ...

  7. Unity资源管理机制

    转载:https://unity3d.com/learn/tutorials/topics/best-practices/assets-objects-and-serialization Assets ...

  8. General-Purpose Operating System Protection Profile

    1 Protection Profile Introduction   This document defines the security functionality expected to be ...

  9. unity如何查找某个脚本挂在了哪些物体上

    在开发中往往会遇到一个问题:不知道整个场景中究竟有哪些物体挂载了某一个脚本.如果挨个查找太麻烦了,下面有一种方法可以快速找到解决这个问题. 在unity的Window里有一项Editor tests ...

随机推荐

  1. Mobile Assistant

    闲来无事,分享一个小东西--手机小助手,历时两周,这里选择几个不错的界面以示效果! 如果有感兴趣的部分,欢迎随时交流!

  2. HDU 2610 (自己完全找不到思路) Sequence one

    搜索虐我千百遍,我待搜索...好吧,我还木有初恋 题意: 我开始理解题意就理解偏了,Orz 题中有n个元素构成的序列,求出前p个非递减子序列.子序列是先按长度排序的,然后按原序列先后位置排序的. 这里 ...

  3. 在页面中使用js

    JavaScript:用来在页面编写特效的,和HTML\CSS一样当都是由浏览器解析 JavaScript语言 一.JS如何运行(JavaScript,jscript,VbScript,applet ...

  4. 通过javascript把图片转化为字符画

    1.获取上传图片对象数据 Javascript无法直接获取本地上传的图片的数据,html5可以解决这一问题 .html5里面的FileReader interface可以把图片对象的数据读到内存,然后 ...

  5. DelegatingFilterProxy

    安全过滤器链 Spring Security的web架构是完全基于标准的servlet过滤器的. 它没有在内部使用servlet或任何其他基于servlet的框架(比如spring mvc), 所以它 ...

  6. ecshop 用户名和邮箱都能登陆

    1.打开/includes/modules/integrates/integrate.php文件,并找到下面代码 if ($this->check_user($username, $passwo ...

  7. nodejs开发阶段利器supervisor

    在开始学习nodejs时,往往一般写代码,一边看效果.先停止node,再重新运行.非常耗时. 这时supervisor派上了用场. 安装 推荐使用npm,本人一直使用局部安装,这样可以将全部文件安装在 ...

  8. Android EventBus源码解析

    项目地址 :https://github.com/greenrobot/EventBus 这个项目个人感觉就是为了解决回调事件过多的,比方说A函数在做完以后 要调用b类的c函数,那我们通常的做法就是 ...

  9. C#实现CAD数据转shape或mdb

    jojojojo2002 原文C#实现CAD数据转shape或mdb 本文所指的CAD数据为不带空间参考和扩展数据的数据.如果CAD带了空间参考或是扩展属性数据的话,就要采用图形和属性分离的方法转CA ...

  10. delphi TClientDataSet 保存到XML

    procedure ExPortNodeQuantifyComponent1(aCDS: TClientDataSet; aCurrNode: TXMLNode); var mStream: TMem ...