GameObject.Find()优点: 使用简单方便不会因为重名而报错,同时查找的是自上而下的第一个物体缺点 不能查找被隐藏的物体,否则出现“空引用异常”,这是很多新人在查找出现空引用bug的原因.全局查找(遍历查找),查找效率低,很消耗性能.代码演示: using System.Collections;using System.Collections.Generic;using UnityEngine; public class GameObjectFind : MonoBehaviour
Primitive and Placeholder Objects 原始的基础物体 Unity can work with 3D models of any shape that can be created with modelling software. However, there are also a number of primitive object types that can be created directly within Unity, namely the Cube, S
Unity中查找脚本被哪些Prefab或场景引用 Unity中有个Find References In Scene的功能,可是仅仅能查找在当前场景中的引用. 假设发现某个脚本不知道被挂在哪个Prefab上了,以下这个脚本你可能用得到 实如今查找脚本在哪些Prefab或者场景中被引用.查找脚本引用了哪些对象(脚本,Texture,字体等) 先看截图: 源代码在这里 using UnityEngine; using UnityEditor; using System.Collections; usi