Unity3D核心类型

Unity3D核心类型一览

 

Unity3D核心类型_第1张图片

本文记录了Unity3D的最基本的核心类型。包括Object、GameObject、Component、Transform、Behaviour、Renderer、Collider、Rigidbody、Camera、Light、MonoBehaviour等。

需要展开了public类型方法的类图请点这里(http://www.cnblogs.com/bitzhuwei/gallery/image/152116.html)。

最核心的类型就这几个:Object、GameObject、Component、Behaviour、MonoBehaviour。

Unity3D核心类型_第2张图片 

需要展开了这几个public类型方法的类图请点这里(http://www.cnblogs.com/bitzhuwei/gallery/image/152118.html)。

UnityEngine.Object

所有Unity3D的基类。

持有实例的ID信息。

实现了静态方法:增(Instantiate)删(Destroy)查(FindObjectsOfType) 

Any public variable you make that derives from Object gets shown in the inspector as a drop target, allowing you to set the value from the GUI.

namespace UnityEngine
{
    using System;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using UnityEngine.Internal;
    using UnityEngineInternal;


    [StructLayout(LayoutKind.Sequential)]
    public class Object
    {
        private ReferenceData m_UnityRuntimeReferenceData;
        private string m_UnityRuntimeErrorString;
        public override bool Equals(object o)
        {
            return CompareBaseObjects(this, o as UnityEngine.Object);
        }


        public override int GetHashCode()
        {
            return this.GetInstanceID();
        }


        private static bool CompareBaseObjects(UnityEngine.Object lhs, UnityEngine.Object rhs)
        {
            return CompareBaseObjectsInternal(lhs, rhs);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private static extern bool CompareBaseObjectsInternal([Writable] UnityEngine.Object lhs, [Writable] UnityEngine.Object rhs);
        [NotRenamed]
        public int GetInstanceID()
        {
            return this.m_UnityRuntimeReferenceData.instanceID;
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private static extern UnityEngine.Object Internal_CloneSingle(UnityEngine.Object data);
        private static UnityEngine.Object Internal_InstantiateSingle(UnityEngine.Object data, Vector3 pos, Quaternion rot)
        {
            return INTERNAL_CALL_Internal_InstantiateSingle(data, ref pos, ref rot);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private static extern UnityEngine.Object INTERNAL_CALL_Internal_InstantiateSingle(UnityEngine.Object data, ref Vector3 pos, ref Quaternion rot);
        [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)]
        public static UnityEngine.Object Instantiate(UnityEngine.Object original, Vector3 position, Quaternion rotation)
        {
            CheckNullArgument(original, "The prefab you want to instantiate is null.");
            return Internal_InstantiateSingle(original, position, rotation);
        }


        [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)]
        public static UnityEngine.Object Instantiate(UnityEngine.Object original)
        {
            CheckNullArgument(original, "The thing you want to instantiate is null.");
            return Internal_CloneSingle(original);
        }


        private static void CheckNullArgument(object arg, string message)
        {
            if (arg == null)
            {
                throw new ArgumentException(message);
            }
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern void Destroy(UnityEngine.Object obj, [DefaultValue("0.0F")] float t);
        [ExcludeFromDocs]
        public static void Destroy(UnityEngine.Object obj)
        {
            float t = 0f;
            Destroy(obj, t);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern void DestroyImmediate(UnityEngine.Object obj, [DefaultValue("false")] bool allowDestroyingAssets);
        [ExcludeFromDocs]
        public static void DestroyImmediate(UnityEngine.Object obj)
        {
            bool allowDestroyingAssets = false;
            DestroyImmediate(obj, allowDestroyingAssets);
        }


        [MethodImpl(MethodImplOptions.InternalCall), TypeInferenceRule(TypeInferenceRules.ArrayOfTypeReferencedByFirstArgument), WrapperlessIcall]
        public static extern UnityEngine.Object[] FindObjectsOfType(System.Type type);
        public static T[] FindObjectsOfType() where T: UnityEngine.Object
        {
            return Resources.ConvertObjects(FindObjectsOfType(typeof(T)));
        }


        [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
        public static UnityEngine.Object FindObjectOfType(System.Type type)
        {
            UnityEngine.Object[] objArray = FindObjectsOfType(type);
            if (objArray.Length > 0)
            {
                return objArray[0];
            }
            return null;
        }


        public static T FindObjectOfType() where T: UnityEngine.Object
        {
            return (T) FindObjectOfType(typeof(T));
        }


        public string name { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern void DontDestroyOnLoad(UnityEngine.Object target);
        public HideFlags hideFlags { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern void DestroyObject(UnityEngine.Object obj, [DefaultValue("0.0F")] float t);
        [ExcludeFromDocs]
        public static void DestroyObject(UnityEngine.Object obj)
        {
            float t = 0f;
            DestroyObject(obj, t);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall, Obsolete("use Object.FindObjectsOfType instead.")]
        public static extern UnityEngine.Object[] FindSceneObjectsOfType(System.Type type);
        [MethodImpl(MethodImplOptions.InternalCall), Obsolete("use Resources.FindObjectsOfTypeAll instead."), WrapperlessIcall]
        public static extern UnityEngine.Object[] FindObjectsOfTypeIncludingAssets(System.Type type);
        [Obsolete("Please use Resources.FindObjectsOfTypeAll instead")]
        public static UnityEngine.Object[] FindObjectsOfTypeAll(System.Type type)
        {
            return Resources.FindObjectsOfTypeAll(type);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public override extern string ToString();
        public static implicit operator bool(UnityEngine.Object exists)
        {
            return !CompareBaseObjects(exists, null);
        }


        public static bool operator ==(UnityEngine.Object x, UnityEngine.Object y)
        {
            return CompareBaseObjects(x, y);
        }


        public static bool operator !=(UnityEngine.Object x, UnityEngine.Object y)
        {
            return !CompareBaseObjects(x, y);
        }
    }
}



UnityEngine.GameObject

///


/// game object contains components.
/// Add Component
/// Find Component
/// common components
/// BroadcastMessage在这个游戏物体及其子物体的所有MonoBehaviour中调用名称为methodName的方法.
///

 GameObject.active is obsolete. Use  GameObject.SetActive() ,   GameObject.activeSelf(read only) or  GameObject.activeInHierarchy(read only) . 

 gameObject.SetActiveRecursively() is obsolete. Use  GameObject.SetActive(), which is now inherited by children.


namespace UnityEngine
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using UnityEngine.Internal;
    using UnityEngineInternal;


    public sealed class GameObject : UnityEngine.Object
    {
        public GameObject()
        {
            Internal_CreateGameObject(this, null);
        }


        public GameObject(string name)
        {
            Internal_CreateGameObject(this, name);
        }


        public GameObject(string name, params System.Type[] components)
        {
            Internal_CreateGameObject(this, name);
            foreach (System.Type type in components)
            {
                this.AddComponent(type);
            }
        }


        public T AddComponent() where T: Component
        {
            return (this.AddComponent(typeof(T)) as T);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern Component AddComponent(string className);
        [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
        public Component AddComponent(System.Type componentType)
        {
            return this.Internal_AddComponentWithType(componentType);
        }


        [ExcludeFromDocs]
        public void BroadcastMessage(string methodName)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            object parameter = null;
            this.BroadcastMessage(methodName, parameter, requireReceiver);
        }


        [ExcludeFromDocs]
        public void BroadcastMessage(string methodName, object parameter)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            this.BroadcastMessage(methodName, parameter, requireReceiver);
        }


        public void BroadcastMessage(string methodName, SendMessageOptions options)
        {
            this.BroadcastMessage(methodName, null, options);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void BroadcastMessage(string methodName, [DefaultValue("null")] object parameter, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern bool CompareTag(string tag);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern GameObject CreatePrimitive(PrimitiveType type);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern GameObject Find(string name);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern GameObject[] FindGameObjectsWithTag(string tag);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public static extern GameObject FindGameObjectWithTag(string tag);
        public static GameObject FindWithTag(string tag)
        {
            return FindGameObjectWithTag(tag);
        }


        public T GetComponent() where T: Component
        {
            return (this.GetComponent(typeof(T)) as T);
        }


        public Component GetComponent(string type)
        {
            return this.GetComponentByName(type);
        }


        [MethodImpl(MethodImplOptions.InternalCall), TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument), WrapperlessIcall]
        public extern Component GetComponent(System.Type type);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern Component GetComponentByName(string type);
        public T GetComponentInChildren() where T: Component
        {
            return (this.GetComponentInChildren(typeof(T)) as T);
        }


        [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
        public Component GetComponentInChildren(System.Type type)
        {
            if (this.activeInHierarchy)
            {
                Component component = this.GetComponent(type);
                if (component != null)
                {
                    return component;
                }
            }
            Transform transform = this.transform;
            if (transform != null)
            {
                IEnumerator enumerator = transform.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        Transform current = (Transform) enumerator.Current;
                        Component componentInChildren = current.gameObject.GetComponentInChildren(type);
                        if (componentInChildren != null)
                        {
                            return componentInChildren;
                        }
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable == null)
                    {
                    }
                    disposable.Dispose();
                }
            }
            return null;
        }


        public T GetComponentInParent() where T: Component
        {
            return (this.GetComponentInParent(typeof(T)) as T);
        }


        [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
        public Component GetComponentInParent(System.Type type)
        {
            if (this.activeInHierarchy)
            {
                Component component = this.GetComponent(type);
                if (component != null)
                {
                    return component;
                }
            }
            Transform parent = this.transform.parent;
            if (parent != null)
            {
                while (parent != null)
                {
                    if (parent.gameObject.activeInHierarchy)
                    {
                        Component component2 = parent.gameObject.GetComponent(type);
                        if (component2 != null)
                        {
                            return component2;
                        }
                    }
                    parent = parent.parent;
                }
            }
            return null;
        }


        public T[] GetComponents() where T: Component
        {
            return (T[]) this.GetComponentsInternal(typeof(T), true, false, true, false);
        }


        public void GetComponents(List results) where T: Component
        {
            this.GetComponentsForListInternal(typeof(T), typeof(T), false, true, false, results);
        }


        [CanConvertToFlash]
        public Component[] GetComponents(System.Type type)
        {
            return this.GetComponentsInternal(type, false, false, true, false);
        }


        public void GetComponents(System.Type type, List results)
        {
            this.GetComponentsForListInternal(type, typeof(Component), false, true, false, results);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern void GetComponentsForListInternal(System.Type searchType, System.Type listElementType, bool recursive, bool includeInactive, bool reverse, object resultList);
        public T[] GetComponentsInChildren() where T: Component
        {
            return this.GetComponentsInChildren(false);
        }


        public T[] GetComponentsInChildren(bool includeInactive) where T: Component
        {
            return (T[]) this.GetComponentsInternal(typeof(T), true, true, includeInactive, false);
        }


        [ExcludeFromDocs]
        public Component[] GetComponentsInChildren(System.Type type)
        {
            bool includeInactive = false;
            return this.GetComponentsInChildren(type, includeInactive);
        }


        public void GetComponentsInChildren(List results) where T: Component
        {
            this.GetComponentsInChildren(false, results);
        }


        public void GetComponentsInChildren(bool includeInactive, List results) where T: Component
        {
            this.GetComponentsForListInternal(typeof(T), typeof(T), true, includeInactive, false, results);
        }


        public Component[] GetComponentsInChildren(System.Type type, [DefaultValue("false")] bool includeInactive)
        {
            return this.GetComponentsInternal(type, false, true, includeInactive, false);
        }


        public T[] GetComponentsInParent() where T: Component
        {
            return this.GetComponentsInParent(false);
        }


        public T[] GetComponentsInParent(bool includeInactive) where T: Component
        {
            return (T[]) this.GetComponentsInternal(typeof(T), true, true, includeInactive, true);
        }


        [ExcludeFromDocs]
        public Component[] GetComponentsInParent(System.Type type)
        {
            bool includeInactive = false;
            return this.GetComponentsInParent(type, includeInactive);
        }


        public void GetComponentsInParent(bool includeInactive, List results) where T: Component
        {
            this.GetComponentsForListInternal(typeof(T), typeof(T), true, includeInactive, true, results);
        }


        public Component[] GetComponentsInParent(System.Type type, [DefaultValue("false")] bool includeInactive)
        {
            return this.GetComponentsInternal(type, false, true, includeInactive, true);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern Component[] GetComponentsInternal(System.Type type, bool isGenericTypeArray, bool recursive, bool includeInactive, bool reverse);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern Component Internal_AddComponentWithType(System.Type componentType);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private static extern void Internal_CreateGameObject([Writable] GameObject mono, string name);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall, Obsolete("gameObject.PlayAnimation is not supported anymore. Use animation.Play")]
        public extern void PlayAnimation(AnimationClip animation);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void SampleAnimation(AnimationClip animation, float time);
        [ExcludeFromDocs]
        public void SendMessage(string methodName)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            object obj2 = null;
            this.SendMessage(methodName, obj2, requireReceiver);
        }


        [ExcludeFromDocs]
        public void SendMessage(string methodName, object value)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            this.SendMessage(methodName, value, requireReceiver);
        }


        public void SendMessage(string methodName, SendMessageOptions options)
        {
            this.SendMessage(methodName, null, options);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void SendMessage(string methodName, [DefaultValue("null")] object value, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options);
        [ExcludeFromDocs]
        public void SendMessageUpwards(string methodName)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            object obj2 = null;
            this.SendMessageUpwards(methodName, obj2, requireReceiver);
        }


        [ExcludeFromDocs]
        public void SendMessageUpwards(string methodName, object value)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            this.SendMessageUpwards(methodName, value, requireReceiver);
        }


        public void SendMessageUpwards(string methodName, SendMessageOptions options)
        {
            this.SendMessageUpwards(methodName, null, options);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void SendMessageUpwards(string methodName, [DefaultValue("null")] object value, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void SetActive(bool value);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall, Obsolete("gameObject.SetActiveRecursively() is obsolete. Use GameObject.SetActive(), which is now inherited by children.")]
        public extern void SetActiveRecursively(bool state);
        [MethodImpl(MethodImplOptions.InternalCall), Obsolete("gameObject.StopAnimation is not supported anymore. Use animation.Stop"), WrapperlessIcall]
        public extern void StopAnimation();


        [Obsolete("GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.")]
        public bool active { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }


        public bool activeInHierarchy { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public bool activeSelf { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Animation animation { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public AudioSource audio { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Camera camera { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Collider collider { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Collider2D collider2D { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public ConstantForce constantForce { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public GameObject gameObject
        {
            get
            {
                return this;
            }
        }


        [Obsolete("Please use guiTexture instead")]
        public GUIElement guiElement { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public GUIText guiText { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public GUITexture guiTexture { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public HingeJoint hingeJoint { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public bool isStatic { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }


        internal bool isStaticBatchable { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public int layer { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }


        public Light light { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public NetworkView networkView { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public ParticleEmitter particleEmitter { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public ParticleSystem particleSystem { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Renderer renderer { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Rigidbody rigidbody { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Rigidbody2D rigidbody2D { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public string tag { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }


        public Transform transform { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }
    }
}


UnityEngine.Component

所有的Component,都会指向其所属的GameObject。

在脚本中用 this.renderer , this.transform , this.GetComponent(XXX) , this.gameObject 与 this.gameObject.renderer , this.gameObject.transform , this.gameObject.GetComponent(XXX) , this.gameObject.gameObject 的结果是完全一样的。这意味着,你用 this.renderer.transform.renderer.collider 这种写法,仍然可以得到 this.collider 。(在这些组件不是 null 的前提下)

the  active property is deprecated on components. Please use  gameObject.active instead. If you meant to enable / disable a single component use  enabled instead.

 GameObject.active  is obsolete. Use  GameObject.SetActive(),  GameObject.activeSelf(read only) or  GameObject.activeInHierarchy(read only) . 

namespace UnityEngine
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using UnityEngine.Internal;
    using UnityEngineInternal;


    public class Component : UnityEngine.Object
    {
        [ExcludeFromDocs]
        public void BroadcastMessage(string methodName)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            object parameter = null;
            this.BroadcastMessage(methodName, parameter, requireReceiver);
        }


        [ExcludeFromDocs]
        public void BroadcastMessage(string methodName, object parameter)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            this.BroadcastMessage(methodName, parameter, requireReceiver);
        }


        public void BroadcastMessage(string methodName, SendMessageOptions options)
        {
            this.BroadcastMessage(methodName, null, options);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void BroadcastMessage(string methodName, [DefaultValue("null")] object parameter, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern bool CompareTag(string tag);
        public T GetComponent() where T: Component
        {
            return (this.GetComponent(typeof(T)) as T);
        }


        public Component GetComponent(string type)
        {
            return this.gameObject.GetComponent(type);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall, TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
        public extern Component GetComponent(System.Type type);
        public T GetComponentInChildren() where T: Component
        {
            return (T) this.GetComponentInChildren(typeof(T));
        }


        [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
        public Component GetComponentInChildren(System.Type t)
        {
            return this.gameObject.GetComponentInChildren(t);
        }


        public T GetComponentInParent() where T: Component
        {
            return (T) this.GetComponentInParent(typeof(T));
        }


        [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
        public Component GetComponentInParent(System.Type t)
        {
            return this.gameObject.GetComponentInParent(t);
        }


        public T[] GetComponents() where T: Component
        {
            return (T[]) this.GetComponentsWithCorrectReturnType(typeof(T));
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern Component[] GetComponents(System.Type type);
        public void GetComponents(List results) where T: Component
        {
            this.GetComponentsForListInternal(typeof(T), typeof(T), false, true, results);
        }


        public void GetComponents(System.Type type, List results)
        {
            this.GetComponentsForListInternal(type, typeof(Component), false, true, results);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern void GetComponentsForListInternal(System.Type searchType, System.Type listElementType, bool recursive, bool includeInactive, object resultList);
        public T[] GetComponentsInChildren() where T: Component
        {
            return this.GetComponentsInChildren(false);
        }


        public T[] GetComponentsInChildren(bool includeInactive) where T: Component
        {
            return this.gameObject.GetComponentsInChildren(includeInactive);
        }


        public void GetComponentsInChildren(List results) where T: Component
        {
            this.GetComponentsInChildren(false, results);
        }


        [ExcludeFromDocs]
        public Component[] GetComponentsInChildren(System.Type t)
        {
            bool includeInactive = false;
            return this.GetComponentsInChildren(t, includeInactive);
        }


        public void GetComponentsInChildren(bool includeInactive, List result) where T: Component
        {
            this.gameObject.GetComponentsInChildren(includeInactive, result);
        }


        public Component[] GetComponentsInChildren(System.Type t, [DefaultValue("false")] bool includeInactive)
        {
            return this.gameObject.GetComponentsInChildren(t, includeInactive);
        }


        public T[] GetComponentsInParent() where T: Component
        {
            return this.GetComponentsInParent(false);
        }


        public T[] GetComponentsInParent(bool includeInactive) where T: Component
        {
            return this.gameObject.GetComponentsInParent(includeInactive);
        }


        [ExcludeFromDocs]
        public Component[] GetComponentsInParent(System.Type t)
        {
            bool includeInactive = false;
            return this.GetComponentsInParent(t, includeInactive);
        }


        public Component[] GetComponentsInParent(System.Type t, [DefaultValue("false")] bool includeInactive)
        {
            return this.gameObject.GetComponentsInParent(t, includeInactive);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern Component[] GetComponentsWithCorrectReturnType(System.Type type);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        internal extern GameObject InternalGetGameObject();
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        internal extern Transform InternalGetTransform();
        [ExcludeFromDocs]
        public void SendMessage(string methodName)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            object obj2 = null;
            this.SendMessage(methodName, obj2, requireReceiver);
        }


        [ExcludeFromDocs]
        public void SendMessage(string methodName, object value)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            this.SendMessage(methodName, value, requireReceiver);
        }


        public void SendMessage(string methodName, SendMessageOptions options)
        {
            this.SendMessage(methodName, null, options);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void SendMessage(string methodName, [DefaultValue("null")] object value, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options);
        [ExcludeFromDocs]
        public void SendMessageUpwards(string methodName)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            object obj2 = null;
            this.SendMessageUpwards(methodName, obj2, requireReceiver);
        }


        [ExcludeFromDocs]
        public void SendMessageUpwards(string methodName, object value)
        {
            SendMessageOptions requireReceiver = SendMessageOptions.RequireReceiver;
            this.SendMessageUpwards(methodName, value, requireReceiver);
        }


        public void SendMessageUpwards(string methodName, SendMessageOptions options)
        {
            this.SendMessageUpwards(methodName, null, options);
        }


        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void SendMessageUpwards(string methodName, [DefaultValue("null")] object value, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options);


        [Obsolete("the active property is deprecated on components. Please use gameObject.active instead. If you meant to enable / disable a single component use enabled instead.")]
        public bool active { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }


        public Animation animation { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public AudioSource audio { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Camera camera { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Collider collider { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Collider2D collider2D { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public ConstantForce constantForce { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public GameObject gameObject
        {
            get
            {
                return this.InternalGetGameObject();
            }
        }


        [Obsolete("Please use guiTexture instead")]
        public GUIElement guiElement { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public GUIText guiText { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public GUITexture guiTexture { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public HingeJoint hingeJoint { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Light light { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public NetworkView networkView { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public ParticleEmitter particleEmitter { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public ParticleSystem particleSystem { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Renderer renderer { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Rigidbody rigidbody { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public Rigidbody2D rigidbody2D { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }


        public string tag { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }


        public Transform transform
        {
            get
            {
                return this.InternalGetTransform();
            }
        }
    }
}
//this.gameObject.active = false;//GameObject.active is obselete
        this.gameObject.SetActive(false);// ! use this to write
        this.gameObject.activeSelf = false;//readonly
        this.gameObject.activeInHierarchy = false;//readonly


        //this.active = false;//Component.active is obsolete
        this.transform.active = false;//cannot disable singly
        this.particleSystem.active = false;//cannot disable singly
        this.rigidbody.active = false;//cannot disable singly


        this.GetComponent().enabled = false;//work on single behaviour
        this.renderer.enabled = false;//work on single renderer
        this.collider.enabled = false;//work on single collider


你可能感兴趣的:(unity)