UnityEditor.CustomEditorAttributes.IsAppropriateEditor C# (CSharp) Method

IsAppropriateEditor() private static method

private static IsAppropriateEditor ( MonoEditorType editor, Type parentClass, bool isChildClass, bool isFallback ) : bool
editor MonoEditorType
parentClass System.Type
isChildClass bool
isFallback bool
return bool
        private static bool IsAppropriateEditor(MonoEditorType editor, Type parentClass, bool isChildClass, bool isFallback)
        {
            if (isChildClass && !editor.m_EditorForChildClasses)
            {
                return false;
            }
            if (isFallback != editor.m_IsFallback)
            {
                return false;
            }
            return (parentClass == editor.m_InspectedType);
        }

Usage Example

示例#1
0
        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;
            }
            Type result;

            if (type == null)
            {
                result = null;
            }
            else
            {
                Dictionary <Type, Type> dictionary = (!multiEdit) ? CustomEditorAttributes.kCachedEditorForType : CustomEditorAttributes.kCachedMultiEditorForType;
                Type inspectorType;
                if (dictionary.TryGetValue(type, out inspectorType))
                {
                    result = inspectorType;
                }
                else
                {
                    List <CustomEditorAttributes.MonoEditorType> list = (!multiEdit) ? CustomEditorAttributes.kSCustomEditors : CustomEditorAttributes.kSCustomMultiEditors;
                    for (int j = 0; j < 2; j++)
                    {
                        for (Type type2 = type; type2 != null; type2 = type2.BaseType)
                        {
                            for (int k = 0; k < list.Count; k++)
                            {
                                if (CustomEditorAttributes.IsAppropriateEditor(list[k], type2, type != type2, j == 1))
                                {
                                    inspectorType = list[k].m_InspectorType;
                                    dictionary.Add(type, inspectorType);
                                    result = inspectorType;
                                    return(result);
                                }
                            }
                        }
                    }
                    dictionary.Add(type, null);
                    result = null;
                }
            }
            return(result);
        }
All Usage Examples Of UnityEditor.CustomEditorAttributes::IsAppropriateEditor