static UnityType() { UnityType.UnityTypeTransport[] array = UnityType.Internal_GetAllTypes(); UnityType.ms_types = new UnityType[array.Length]; UnityType.ms_idToTypeInfo = new Dictionary <int, UnityType>(); UnityType.ms_nameToTypeInfo = new Dictionary <string, UnityType>(); for (int i = 0; i < array.Length; i++) { UnityType baseClass = null; if ((ulong)array[i].baseClassIndex < (ulong)((long)array.Length)) { baseClass = UnityType.ms_types[(int)((UIntPtr)array[i].baseClassIndex)]; } UnityType unityType = new UnityType { runtimeTypeIndex = array[i].runtimeTypeIndex, descendantCount = array[i].descendantCount, name = array[i].className, nativeNamespace = array[i].classNamespace, persistentTypeID = array[i].persistentTypeID, baseClass = baseClass, flags = (UnityTypeFlags)array[i].flags }; UnityType.ms_types[i] = unityType; UnityType.ms_typesReadOnly = new ReadOnlyCollection <UnityType>(UnityType.ms_types); UnityType.ms_idToTypeInfo[unityType.persistentTypeID] = unityType; UnityType.ms_nameToTypeInfo[unityType.name] = unityType; } }
static UnityType() { var types = UnityType.Internal_GetAllTypes(); ms_types = new UnityType[types.Length]; ms_idToType = new Dictionary <int, UnityType>(); ms_nameToType = new Dictionary <string, UnityType>(); for (int i = 0; i < types.Length; ++i) { // Types are sorted so base < derived and null baseclass is passed from native as 0xffffffff UnityType baseClass = null; if (types[i].baseClassIndex < types.Length) { baseClass = ms_types[types[i].baseClassIndex]; } var newType = new UnityType { runtimeTypeIndex = types[i].runtimeTypeIndex, descendantCount = types[i].descendantCount, name = types[i].className, nativeNamespace = types[i].classNamespace, module = types[i].module, persistentTypeID = types[i].persistentTypeID, baseClass = baseClass, flags = (UnityTypeFlags)types[i].flags }; Debug.Assert(types[i].runtimeTypeIndex == i); ms_types[i] = newType; ms_typesReadOnly = new ReadOnlyCollection <UnityType>(ms_types); ms_idToType[newType.persistentTypeID] = newType; ms_nameToType[newType.name] = newType; } }