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. R语言的向量化编程思维

    1.计算缺失值比例 perNA<- mean(is.na(Data1)) 2.按值替换 #which返回值是符合条件的下标 NAIDX<- which(Data2<=3 | Data ...

  2. bzoj4127

    肯定是树链剖分+线段树,关键是怎么维护 绝对值和这个东西显然不能简单的合并标记 因为对于负数,加之后绝对值和是变小的 那我们考虑对负数和非负数数分别维护 下面的问题就是经过操作如果负数变成了正数怎么办 ...

  3. UVa (二分) 11627 Slalom

    题意: 有宽度相同的水平的n个旗门,水平(纵坐标严格递增)滑行的最大速度为Vh(水平速度可以任意调节).然后还有S双滑雪板,每双滑雪板的垂直速度一定. 然后求能通过的滑板鞋的最大速度. 分析: 显然, ...

  4. 堆Heap

    #pragma once#include <vector> // 小堆template<class T>  //仿函数struct Less{       bool opera ...

  5. 【英语】Bingo口语笔记(60) - 口语中的浊化发音

  6. 【阅读】提问的智慧+有效的报告BUG

    这两项可谓是我们测试人员的基本要求了,不过实话说的是,我自己这两方面很薄弱.哎!!! 这两篇文章都看过了,不过我在这也记个笔记吧.督促自己!!! <提问的智慧> <如何有效地报告Bu ...

  7. Maven加依赖包

    对于初学maven的人来说刚开始会有个困惑,那就是怎么知道依赖的jar的groupId和atrifactId是什么, 比如要依赖mybatis,会在pom.xml中配置如下: <dependen ...

  8. ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)

    不论是单实例还是RAC,对于非缺省端口下(1521)的监听器,pmon进程不会将service/instance注册到监听器,即不会实现动态注册.与单实例相同,RAC非缺省端口的监听器也是通过设置参数 ...

  9. spring mvc 异常统一处理方式

    springMVC提供的异常处理主要有两种方式: 一种是直接实现自己的HandlerExceptionResolver: 另一种是使用注解的方式实现一个专门用于处理异常的Controller——Exc ...

  10. ScrollView中嵌套ListView

    scrollview中嵌入listview,要是直接把listview嵌进scrollview中,listview的高度是固定的不能进行滑动.默认情况下Android是禁止在ScrollView中放入 ...