UnityEditor.CustomEditorAttributes.Rebuild C# (CSharp) Method

Rebuild() static private method

static private Rebuild ( Assembly assembly ) : void
assembly System.Reflection.Assembly
return void
        internal static void Rebuild(Assembly assembly)
        {
            Type[] typesFromAssembly = AssemblyHelper.GetTypesFromAssembly(assembly);
            foreach (Type type in typesFromAssembly)
            {
                object[] customAttributes = type.GetCustomAttributes(typeof(CustomEditor), false);
                foreach (CustomEditor editor in customAttributes)
                {
                    MonoEditorType item = new MonoEditorType();
                    if (editor.m_InspectedType == null)
                    {
                        Debug.Log("Can't load custom inspector " + type.Name + " because the inspected type is null.");
                    }
                    else if (!type.IsSubclassOf(typeof(Editor)))
                    {
                        if (((type.FullName != "TweakMode") || !type.IsEnum) || (editor.m_InspectedType.FullName != "BloomAndFlares"))
                        {
                            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
                    {
                        item.m_InspectedType = editor.m_InspectedType;
                        item.m_InspectorType = type;
                        item.m_EditorForChildClasses = editor.m_EditorForChildClasses;
                        item.m_IsFallback = editor.isFallback;
                        kSCustomEditors.Add(item);
                        if (type.GetCustomAttributes(typeof(CanEditMultipleObjects), false).Length > 0)
                        {
                            kSCustomMultiEditors.Add(item);
                        }
                    }
                }
            }
        }

Usage Example

        internal static Type FindCustomEditorTypeByType(Type type, bool multiEdit)
        {
            if (!CustomEditorAttributes.s_Initialized)
            {
                Assembly[] loadedAssemblies = EditorAssemblies.loadedAssemblies;
                for (int i = loadedAssemblies.Length - 1; i >= 0; i--)
                {
                    CustomEditorAttributes.Rebuild(loadedAssemblies[i]);
                }
                CustomEditorAttributes.s_Initialized = true;
            }
            List <CustomEditorAttributes.MonoEditorType> source = (!multiEdit) ? CustomEditorAttributes.kSCustomEditors : CustomEditorAttributes.kSCustomMultiEditors;
            Type inspected;

            for (inspected = type; inspected != null; inspected = inspected.BaseType)
            {
                CustomEditorAttributes.MonoEditorType monoEditorType;
                if (type == inspected)
                {
                    monoEditorType = source.FirstOrDefault((CustomEditorAttributes.MonoEditorType x) => inspected == x.m_InspectedType);
                }
                else
                {
                    monoEditorType = source.FirstOrDefault((CustomEditorAttributes.MonoEditorType x) => inspected == x.m_InspectedType && x.m_EditorForChildClasses);
                }
                if (monoEditorType != null)
                {
                    return(monoEditorType.m_InspectorType);
                }
            }
            return(null);
        }
All Usage Examples Of UnityEditor.CustomEditorAttributes::Rebuild