static void UpdateSkyTypes() { if (m_SkyTypesDict == null) { m_SkyTypesDict = new Dictionary <int, Type>(); var skyTypes = CoreUtils.GetAllAssemblyTypes().Where(t => t.IsSubclassOf(typeof(SkySettings)) && !t.IsAbstract); foreach (Type skyType in skyTypes) { var uniqueIDs = skyType.GetCustomAttributes(typeof(SkyUniqueID), false); if (uniqueIDs.Length == 0) { Debug.LogWarningFormat("Missing attribute SkyUniqueID on class {0}. Class won't be registered as an available sky.", skyType); } else { int uniqueID = ((SkyUniqueID)uniqueIDs[0]).uniqueID; if (uniqueID == 0) { Debug.LogWarningFormat("0 is a reserved SkyUniqueID and is used in class {0}. Class won't be registered as an available sky.", skyType); continue; } Type value; if (m_SkyTypesDict.TryGetValue(uniqueID, out value)) { Debug.LogWarningFormat("SkyUniqueID {0} used in class {1} is already used in class {2}. Class won't be registered as an available sky.", uniqueID, skyType, value); continue; } m_SkyTypesDict.Add(uniqueID, skyType); } } } }
static string[] s_DisplayTypes; // Pretty names static DebugUIHandlerCanvasEditor() { s_Types = CoreUtils.GetAllAssemblyTypes() .Where(t => t.IsSubclassOf(typeof(DebugUI.Widget)) && !t.IsAbstract) .Select(t => t.AssemblyQualifiedName) .ToArray(); s_DisplayTypes = new string[s_Types.Length]; for (int i = 0; i < s_Types.Length; i++) { s_DisplayTypes[i] = Type.GetType(s_Types[i]).Name; } }
static void RebuildTypeMaps() { var assemblyTypes = CoreUtils.GetAllAssemblyTypes(); // Map states to widget (a single state can map to several widget types if the value to // serialize is the same) var attrType = typeof(DebugStateAttribute); var stateTypes = assemblyTypes .Where( t => t.IsSubclassOf(typeof(DebugState)) && t.IsDefined(attrType, false) && !t.IsAbstract ); s_WidgetStateMap = new Dictionary <Type, Type>(); foreach (var stateType in stateTypes) { var attr = (DebugStateAttribute)stateType.GetCustomAttributes(attrType, false)[0]; foreach (var t in attr.types) { s_WidgetStateMap.Add(t, stateType); } } // Drawers attrType = typeof(DebugUIDrawerAttribute); var types = assemblyTypes .Where( t => t.IsSubclassOf(typeof(DebugUIDrawer)) && t.IsDefined(attrType, false) && !t.IsAbstract ); s_WidgetDrawerMap = new Dictionary <Type, DebugUIDrawer>(); foreach (var t in types) { var attr = (DebugUIDrawerAttribute)t.GetCustomAttributes(attrType, false)[0]; var inst = (DebugUIDrawer)Activator.CreateInstance(t); s_WidgetDrawerMap.Add(attr.type, inst); } // Done s_TypeMapDirty = false; }
static void ReloadDecoratorTypes() { s_ParameterDrawers.Clear(); // Look for all the valid parameter drawers var types = CoreUtils.GetAllAssemblyTypes() .Where( t => t.IsSubclassOf(typeof(VolumeParameterDrawer)) && t.IsDefined(typeof(VolumeParameterDrawerAttribute), false) && !t.IsAbstract ); // Store them foreach (var type in types) { var attr = (VolumeParameterDrawerAttribute)type.GetCustomAttributes(typeof(VolumeParameterDrawerAttribute), false)[0]; var decorator = (VolumeParameterDrawer)Activator.CreateInstance(type); s_ParameterDrawers.Add(attr.parameterType, decorator); } }
void OnEnable() { var o = new PropertyFetcher <Volume>(serializedObject); m_IsGlobal = o.Find(x => x.isGlobal); m_BlendRadius = o.Find(x => x.blendDistance); m_Weight = o.Find(x => x.weight); m_Priority = o.Find(x => x.priority); m_Components = o.Find(x => x.components); m_EditorTypes = new Dictionary <Type, Type>(); m_Editors = new List <VolumeComponentEditor>(); // Gets the list of all available component editors var editorTypes = CoreUtils.GetAllAssemblyTypes() .Where( t => t.IsSubclassOf(typeof(VolumeComponentEditor)) && t.IsDefined(typeof(VolumeComponentEditorAttribute), false) && !t.IsAbstract ); // Map them to their corresponding component type foreach (var editorType in editorTypes) { var attribute = (VolumeComponentEditorAttribute)editorType.GetCustomAttributes(typeof(VolumeComponentEditorAttribute), false)[0]; m_EditorTypes.Add(attribute.componentType, editorType); } // Create editors for existing components var components = actualTarget.components; for (int i = 0; i < components.Count; i++) { CreateEditor(components[i], m_Components.GetArrayElementAtIndex(i)); } // Keep track of undo/redo to redraw the inspector when that happens Undo.undoRedoPerformed += OnUndoRedoPerformed; }
public void Init(VolumeProfile asset, SerializedObject serializedObject) { Assert.IsNotNull(asset); Assert.IsNotNull(serializedObject); this.asset = asset; m_SerializedObject = serializedObject; m_ComponentsProperty = serializedObject.Find((VolumeProfile x) => x.components); Assert.IsNotNull(m_ComponentsProperty); m_EditorTypes = new Dictionary <Type, Type>(); m_Editors = new List <VolumeComponentEditor>(); // Gets the list of all available component editors var editorTypes = CoreUtils.GetAllAssemblyTypes() .Where( t => t.IsSubclassOf(typeof(VolumeComponentEditor)) && t.IsDefined(typeof(VolumeComponentEditorAttribute), false) && !t.IsAbstract ); // Map them to their corresponding component type foreach (var editorType in editorTypes) { var attribute = (VolumeComponentEditorAttribute)editorType.GetCustomAttributes(typeof(VolumeComponentEditorAttribute), false)[0]; m_EditorTypes.Add(attribute.componentType, editorType); } // Create editors for existing components var components = asset.components; for (int i = 0; i < components.Count; i++) { CreateEditor(components[i], m_ComponentsProperty.GetArrayElementAtIndex(i)); } // Keep track of undo/redo to redraw the inspector when that happens Undo.undoRedoPerformed += OnUndoRedoPerformed; }