Beispiel #1
0
        public static LayerImportGUI GetLayerEditor(string suffix)
        {
            LayerImportGUI drawer = null;

            if (drawerDic.ContainsKey(suffix))
            {
                drawer = drawerDic[suffix];
            }

            if (drawer == null || !drawerDic.ContainsKey(suffix))
            {
                drawer = drawerDic[suffix] = GetLayerImportEditor(suffix);
            }
            return(drawer);
        }
Beispiel #2
0
        private static LayerImportGUI GetLayerImportEditor(string suffix)
        {
            if (RuleObj == null)
            {
                Debug.LogError("init enviroment first!");
            }

            var ruleObj  = RuleObj;
            var importer = ruleObj.layerImports.Where(x => string.Compare(x.Suffix, suffix, true) == 0).FirstOrDefault();

            if (importer != null)
            {
                var supportTypes = from editorType in layerImportEditorTypes
                                   let atts = editorType.GetType().GetCustomAttributes(typeof(CustomLayerAttribute), true)
                                              where atts.Count() > 0
                                              select editorType;

                if (supportTypes.Count() > 0)
                {
                    LayerImportGUI layerImportEditor = null;
                    var            type = importer.GetType();
                    while (type != typeof(LayerImport))
                    {
                        layerImportEditor = (from editorType in supportTypes
                                             let att = editorType.GetType().GetCustomAttributes(typeof(CustomLayerAttribute), true)[0] as CustomLayerAttribute
                                                       where att.type == type
                                                       select editorType as LayerImportGUI).FirstOrDefault();

                        if (layerImportEditor != null)
                        {
                            break;
                        }

                        type = type.BaseType;
                    }

                    if (layerImportEditor == null)
                    {
                        layerImportEditor = new EmplyLayerImportEditor();
                    }

                    return(layerImportEditor);
                }
            }
            return(new EmplyLayerImportEditor());
        }