Unity中的Object和object的区别
Object是UnityEngine.Object,是Unity所有组件Component和GameObject的父类;
object在Unity中是System.Object
举个简单的例子:
Debug.Log(gameObject is Object);
Debug.Log(gameObject is object);
前者返回true,后者也返回true;
int num = 5;
Debug.Log(num is Object);
Debug.Log(num is object);
前者返回false,后者返回true;
注意:如果引用了System命名空间,用Object的话会报错,无法区分是System.Object还是UnityEngine.Object,这时候使用Object的时候就需要写明命名空间了,或者头文件中写入
using Object = UnityEngine.Object;