Unity3D核心类型一览
本文记录了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。
需要展开了这几个public类型方法的类图请点这里(http://www.cnblogs.com/bitzhuwei/gallery/image/152118.html)。
所有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.
1 namespace UnityEngine 2 { 3 using System; 4 using System.Runtime.CompilerServices; 5 using System.Runtime.InteropServices; 6 using UnityEngine.Internal; 7 using UnityEngineInternal; 8 9 [StructLayout(LayoutKind.Sequential)] 10 public class Object 11 { 12 private ReferenceData m_UnityRuntimeReferenceData; 13 private string m_UnityRuntimeErrorString; 14 public override bool Equals(object o) 15 { 16 return CompareBaseObjects(this, o as UnityEngine.Object); 17 } 18 19 public override int GetHashCode() 20 { 21 return this.GetInstanceID(); 22 } 23 24 private static bool CompareBaseObjects(UnityEngine.Object lhs, UnityEngine.Object rhs) 25 { 26 return CompareBaseObjectsInternal(lhs, rhs); 27 } 28 29 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 30 private static extern bool CompareBaseObjectsInternal([Writable] UnityEngine.Object lhs, [Writable] UnityEngine.Object rhs); 31 [NotRenamed] 32 public int GetInstanceID() 33 { 34 return this.m_UnityRuntimeReferenceData.instanceID; 35 } 36 37 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 38 private static extern UnityEngine.Object Internal_CloneSingle(UnityEngine.Object data); 39 private static UnityEngine.Object Internal_InstantiateSingle(UnityEngine.Object data, Vector3 pos, Quaternion rot) 40 { 41 return INTERNAL_CALL_Internal_InstantiateSingle(data, ref pos, ref rot); 42 } 43 44 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 45 private static extern UnityEngine.Object INTERNAL_CALL_Internal_InstantiateSingle(UnityEngine.Object data, ref Vector3 pos, ref Quaternion rot); 46 [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)] 47 public static UnityEngine.Object Instantiate(UnityEngine.Object original, Vector3 position, Quaternion rotation) 48 { 49 CheckNullArgument(original, "The prefab you want to instantiate is null."); 50 return Internal_InstantiateSingle(original, position, rotation); 51 } 52 53 [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)] 54 public static UnityEngine.Object Instantiate(UnityEngine.Object original) 55 { 56 CheckNullArgument(original, "The thing you want to instantiate is null."); 57 return Internal_CloneSingle(original); 58 } 59 60 private static void CheckNullArgument(object arg, string message) 61 { 62 if (arg == null) 63 { 64 throw new ArgumentException(message); 65 } 66 } 67 68 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 69 public static extern void Destroy(UnityEngine.Object obj, [DefaultValue("0.0F")] float t); 70 [ExcludeFromDocs] 71 public static void Destroy(UnityEngine.Object obj) 72 { 73 float t = 0f; 74 Destroy(obj, t); 75 } 76 77 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 78 public static extern void DestroyImmediate(UnityEngine.Object obj, [DefaultValue("false")] bool allowDestroyingAssets); 79 [ExcludeFromDocs] 80 public static void DestroyImmediate(UnityEngine.Object obj) 81 { 82 bool allowDestroyingAssets = false; 83 DestroyImmediate(obj, allowDestroyingAssets); 84 } 85 86 [MethodImpl(MethodImplOptions.InternalCall), TypeInferenceRule(TypeInferenceRules.ArrayOfTypeReferencedByFirstArgument), WrapperlessIcall] 87 public static extern UnityEngine.Object[] FindObjectsOfType(System.Type type); 88 public static T[] FindObjectsOfType<T>() where T: UnityEngine.Object 89 { 90 return Resources.ConvertObjects<T>(FindObjectsOfType(typeof(T))); 91 } 92 93 [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] 94 public static UnityEngine.Object FindObjectOfType(System.Type type) 95 { 96 UnityEngine.Object[] objArray = FindObjectsOfType(type); 97 if (objArray.Length > 0) 98 { 99 return objArray[0]; 100 } 101 return null; 102 } 103 104 public static T FindObjectOfType<T>() where T: UnityEngine.Object 105 { 106 return (T) FindObjectOfType(typeof(T)); 107 } 108 109 public string name { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; } 110 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 111 public static extern void DontDestroyOnLoad(UnityEngine.Object target); 112 public HideFlags hideFlags { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; } 113 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 114 public static extern void DestroyObject(UnityEngine.Object obj, [DefaultValue("0.0F")] float t); 115 [ExcludeFromDocs] 116 public static void DestroyObject(UnityEngine.Object obj) 117 { 118 float t = 0f; 119 DestroyObject(obj, t); 120 } 121 122 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall, Obsolete("use Object.FindObjectsOfType instead.")] 123 public static extern UnityEngine.Object[] FindSceneObjectsOfType(System.Type type); 124 [MethodImpl(MethodImplOptions.InternalCall), Obsolete("use Resources.FindObjectsOfTypeAll instead."), WrapperlessIcall] 125 public static extern UnityEngine.Object[] FindObjectsOfTypeIncludingAssets(System.Type type); 126 [Obsolete("Please use Resources.FindObjectsOfTypeAll instead")] 127 public static UnityEngine.Object[] FindObjectsOfTypeAll(System.Type type) 128 { 129 return Resources.FindObjectsOfTypeAll(type); 130 } 131 132 [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] 133 public override extern string ToString(); 134 public static implicit operator bool(UnityEngine.Object exists) 135 { 136 return !CompareBaseObjects(exists, null); 137 } 138 139 public static bool operator ==(UnityEngine.Object x, UnityEngine.Object y) 140 { 141 return CompareBaseObjects(x, y); 142 } 143 144 public static bool operator !=(UnityEngine.Object x, UnityEngine.Object y) 145 { 146 return !CompareBaseObjects(x, y); 147 } 148 } 149 }