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. 使用Jenkins构建持续集成环境

    简介 Jenkins是一个开源的持续集成工具,提供了数百种插件供用户选择,能够完成整套持续集成环境的构建. 它具有如下的特点: 持续集成和持续发布 作为可扩展的自动服务器,Jenkins可以作为简单的 ...

  2. 51nod1119 机器人走方格 V2

    终于学到了求组合数的正确姿势 //C(n+m-2,m-1) #include<cstdio> #include<cstring> #include<cctype> ...

  3. C++实现顺序表

    #include<iostream>using namespace std; typedef int DataType; class SeqList{public:    SeqList( ...

  4. [Swift系列]003- 函数

    [基础] Swift函数格式: 1.定义格式: func   函数名(参数名1:数据类型,... ,参数名n:数据类型) -> (返回值类型1,...,返回值类型n){ ///函数体内语句 } ...

  5. 代码记录:使用Aforge.net让视频图像反转180度

    private void CameraConn() { videoSource = new VideoCaptureDevice(videoDevices[tscbxCameras.SelectedI ...

  6. yaf框架流程二

    这篇讲讲yaf的配置文件,首先上我的配置代码: [common] ;必选配置 ;application.directory String 应用的绝对目录路径 ;可选配置 ;名称 值类型 默认值 说明 ...

  7. Heritrix源码分析(三) 修改配置文件order.xml加快你的抓取速度(转)

    本博客属原创文章,欢迎转载!转载请务必注明出处:http://guoyunsky.iteye.com/blog/629891       本博客已迁移到本人独立博客: http://www.yun5u ...

  8. linux下安装虚拟机qemu kqemu

    一,为什么要装虚拟机,为什么选择qemu 我的系统里面有3个linux系统,这些系统都是独立的,有的时候,我想一台电脑,能更真实的模拟二台,这个时候我们就可以装个虚拟机.其实如果真的很有钱的话,可能考 ...

  9. 自定义视图一:扩展现有的视图,添加新的XML属性

    这个系列是老外写的,干货!翻译出来一起学习.如有不妥,不吝赐教! 简介 这个系列详细的介绍了如何穿件Android自定义视图.主要涉及的内容有如何绘制内容,layout和measure的原理,如何继承 ...

  10. mysql innodb锁简析(1)

    说好的每天一个技术博客,选了iteye,但是,那个界面真的好丑啊,丑的让我都没写下去的欲望了,所以,还是转移到博客园里面吧,虽然这里也是很丑的! 直接步入正题: 1. 数据库锁包括:读锁(可共享锁)和 ...