private static int[] ProcessInitializeOnLoadAttributes() { EditorAssemblies.m_TotalNumRuntimeInitializeMethods = 0; EditorAssemblies.m_RuntimeInitializeClassInfoList = new List <RuntimeInitializeClassInfo>(); foreach (Type current in EditorAssemblies.GetAllTypesWithAttribute <InitializeOnLoadAttribute>()) { EditorAssemblies.ProcessEditorInitializeOnLoad(current); } foreach (MethodInfo current2 in EditorAssemblies.GetAllMethodsWithAttribute <RuntimeInitializeOnLoadMethodAttribute>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { EditorAssemblies.ProcessRuntimeInitializeOnLoad(current2); } foreach (MethodInfo current3 in EditorAssemblies.GetAllMethodsWithAttribute <InitializeOnLoadMethodAttribute>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { EditorAssemblies.ProcessInitializeOnLoadMethod(current3); } return(null); }
static NativeFormatImporterUtility() { NativeFormatImporterUtility.s_RegisteredExtensionsByType = new Dictionary <Type, string[]>(); foreach (Type current in EditorAssemblies.GetAllTypesWithAttribute <AssetFileNameExtensionAttribute>()) { AssetFileNameExtensionAttribute assetFileNameExtensionAttribute = current.GetCustomAttributes(typeof(AssetFileNameExtensionAttribute), false)[0] as AssetFileNameExtensionAttribute; try { NativeFormatImporterUtility.RegisterExtensionForType(current, assetFileNameExtensionAttribute.preferredExtension, assetFileNameExtensionAttribute.otherExtensions.ToArray <string>()); } catch (ArgumentException exception) { Debug.LogException(exception); } catch (NotSupportedException exception2) { Debug.LogException(exception2); } } }
static NativeFormatImporterUtility() { foreach (var type in EditorAssemblies.GetAllTypesWithAttribute <AssetFileNameExtensionAttribute>()) { var attr = type.GetCustomAttributes(typeof(AssetFileNameExtensionAttribute), false)[0] as AssetFileNameExtensionAttribute; try { RegisterExtensionForType(type, attr.preferredExtension, attr.otherExtensions.ToArray()); } catch (ArgumentException e) { Debug.LogException(e); } catch (NotSupportedException e) { Debug.LogException(e); } } }
public static Type GetDefaultBrushType() { Type defaultType = typeof(GridBrush); int count = 0; foreach (var type in EditorAssemblies.GetAllTypesWithAttribute <CustomGridBrushAttribute>()) { var attrs = type.GetCustomAttributes(typeof(CustomGridBrushAttribute), false) as CustomGridBrushAttribute[]; if (attrs != null && attrs.Length > 0) { if (attrs[0].defaultBrush) { defaultType = type; count++; } } } if (count > 1) { Debug.LogWarning("Multiple occurrences of defaultBrush == true found. It should only be declared once."); } return(defaultType); }
public static Type GetDefaultBrushType() { Type result = typeof(GridBrush); int num = 0; foreach (Type current in EditorAssemblies.GetAllTypesWithAttribute <CustomGridBrushAttribute>()) { CustomGridBrushAttribute[] array = current.GetCustomAttributes(typeof(CustomGridBrushAttribute), false) as CustomGridBrushAttribute[]; if (array != null && array.Length > 0) { if (array[0].defaultBrush) { result = current; num++; } } } if (num > 1) { Debug.LogWarning("Multiple occurrences of defaultBrush == true found. It should only be declared once."); } return(result); }
static MonoCreateAssetItem[] ExtractCreateAssetMenuItems(Assembly assembly) { var result = new List <MonoCreateAssetItem>(); foreach (var type in EditorAssemblies.GetAllTypesWithAttribute <CreateAssetMenuAttribute>()) { var attr = type.GetCustomAttributes(typeof(CreateAssetMenuAttribute), false).FirstOrDefault() as CreateAssetMenuAttribute; if (attr == null) { continue; } if (!type.IsSubclassOf(typeof(ScriptableObject))) { Debug.LogWarningFormat("CreateAssetMenu attribute on {0} will be ignored as {0} is not derived from ScriptableObject.", type.FullName); continue; } string menuItemName = (string.IsNullOrEmpty(attr.menuName)) ? ObjectNames.NicifyVariableName(type.Name) : attr.menuName; string fileName = (string.IsNullOrEmpty(attr.fileName)) ? ("New " + ObjectNames.NicifyVariableName(type.Name) + ".asset") : attr.fileName; if (!System.IO.Path.HasExtension(fileName)) { fileName = fileName + ".asset"; } var item = new MonoCreateAssetItem { menuItem = menuItemName, fileName = fileName, order = attr.order, type = type }; result.Add(item); } return(result.ToArray()); }
private static AttributeHelper.MonoCreateAssetItem[] ExtractCreateAssetMenuItems(Assembly assembly) { List <AttributeHelper.MonoCreateAssetItem> list = new List <AttributeHelper.MonoCreateAssetItem>(); foreach (Type current in EditorAssemblies.GetAllTypesWithAttribute <CreateAssetMenuAttribute>()) { CreateAssetMenuAttribute createAssetMenuAttribute = current.GetCustomAttributes(typeof(CreateAssetMenuAttribute), false).FirstOrDefault <object>() as CreateAssetMenuAttribute; if (createAssetMenuAttribute != null) { if (!current.IsSubclassOf(typeof(ScriptableObject))) { UnityEngine.Debug.LogWarningFormat("CreateAssetMenu attribute on {0} will be ignored as {0} is not derived from ScriptableObject.", new object[] { current.FullName }); } else { string menuItem = (!string.IsNullOrEmpty(createAssetMenuAttribute.menuName)) ? createAssetMenuAttribute.menuName : ObjectNames.NicifyVariableName(current.Name); string text = (!string.IsNullOrEmpty(createAssetMenuAttribute.fileName)) ? createAssetMenuAttribute.fileName : ("New " + ObjectNames.NicifyVariableName(current.Name) + ".asset"); if (!Path.HasExtension(text)) { text += ".asset"; } AttributeHelper.MonoCreateAssetItem item = new AttributeHelper.MonoCreateAssetItem { menuItem = menuItem, fileName = text, order = createAssetMenuAttribute.order, type = current }; list.Add(item); } } } return(list.ToArray()); }
internal static void Rebuild() { kSCustomEditors.Clear(); kSCustomMultiEditors.Clear(); var types = EditorAssemblies.GetAllTypesWithAttribute <CustomEditor>(); foreach (var type in types) { object[] attrs = type.GetCustomAttributes(typeof(CustomEditor), false); foreach (CustomEditor inspectAttr in attrs) { var t = new MonoEditorType(); if (inspectAttr.m_InspectedType == null) { Debug.Log("Can't load custom inspector " + type.Name + " because the inspected type is null."); } else if (!type.IsSubclassOf(typeof(Editor))) { // Suppress a warning on TweakMode, we did this bad in the default project folder // and it's going to be too hard for customers to figure out how to fix it and also quite pointless. if (type.FullName == "TweakMode" && type.IsEnum && inspectAttr.m_InspectedType.FullName == "BloomAndFlares") { continue; } Debug.LogWarning( type.Name + " uses the CustomEditor attribute but does not inherit from Editor.\nYou must inherit from Editor. See the Editor class script documentation."); } else { t.m_InspectedType = inspectAttr.m_InspectedType; t.m_InspectorType = type; t.m_EditorForChildClasses = inspectAttr.m_EditorForChildClasses; t.m_IsFallback = inspectAttr.isFallback; var attr = inspectAttr as CustomEditorForRenderPipelineAttribute; if (attr != null) { t.m_RenderPipelineType = attr.renderPipelineType; } List <MonoEditorType> editors; if (!kSCustomEditors.TryGetValue(inspectAttr.m_InspectedType, out editors)) { editors = new List <MonoEditorType>(); kSCustomEditors[inspectAttr.m_InspectedType] = editors; } editors.Add(t); if (type.GetCustomAttributes(typeof(CanEditMultipleObjects), false).Length > 0) { List <MonoEditorType> multiEditors; if (!kSCustomMultiEditors.TryGetValue(inspectAttr.m_InspectedType, out multiEditors)) { multiEditors = new List <MonoEditorType>(); kSCustomMultiEditors[inspectAttr.m_InspectedType] = multiEditors; } multiEditors.Add(t); } } } } }