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
コード例 #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);
        }
コード例 #2
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, List <CustomEditorAttributes.MonoEditorType> > dictionary = (!multiEdit) ? CustomEditorAttributes.kSCustomEditors : CustomEditorAttributes.kSCustomMultiEditors;
                for (int j = 0; j < 2; j++)
                {
                    Type type2 = type;
                    while (type2 != null)
                    {
                        List <CustomEditorAttributes.MonoEditorType> list;
                        if (dictionary.TryGetValue(type2, out list))
                        {
                            goto IL_AB;
                        }
                        if (type2.IsGenericType)
                        {
                            type2 = type2.GetGenericTypeDefinition();
                            if (dictionary.TryGetValue(type2, out list))
                            {
                                goto IL_AB;
                            }
                        }
IL_20E:
                        type2 = type2.BaseType;
                        continue;
IL_AB:
                        CustomEditorAttributes.s_SearchCache.Clear();
                        foreach (CustomEditorAttributes.MonoEditorType current in list)
                        {
                            if (CustomEditorAttributes.IsAppropriateEditor(current, type2, type != type2, j == 1))
                            {
                                CustomEditorAttributes.s_SearchCache.Add(current);
                            }
                        }
                        Type type3 = null;
                        if (GraphicsSettings.renderPipelineAsset != null)
                        {
                            Type type4 = GraphicsSettings.renderPipelineAsset.GetType();
                            foreach (CustomEditorAttributes.MonoEditorType current2 in CustomEditorAttributes.s_SearchCache)
                            {
                                if (current2.m_RenderPipelineType == type4)
                                {
                                    type3 = current2.m_InspectorType;
                                    break;
                                }
                            }
                        }
                        if (type3 == null)
                        {
                            foreach (CustomEditorAttributes.MonoEditorType current3 in CustomEditorAttributes.s_SearchCache)
                            {
                                if (current3.m_RenderPipelineType == null)
                                {
                                    type3 = current3.m_InspectorType;
                                    break;
                                }
                            }
                        }
                        CustomEditorAttributes.s_SearchCache.Clear();
                        if (type3 != null)
                        {
                            result = type3;
                            return(result);
                        }
                        goto IL_20E;
                    }
                }
                result = null;
            }
            return(result);
        }