private static void InitPostprocessors(string pathName)
 {
     AssetPostprocessingInternal.m_ImportProcessors = new ArrayList();
     foreach (System.Type type in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
     {
         try
         {
             AssetPostprocessor instance = Activator.CreateInstance(type) as AssetPostprocessor;
             instance.assetPath = pathName;
             AssetPostprocessingInternal.m_ImportProcessors.Add((object)instance);
         }
         catch (MissingMethodException ex)
         {
             AssetPostprocessingInternal.LogPostProcessorMissingDefaultConstructor(type);
         }
         catch (Exception ex)
         {
             Debug.LogException(ex);
         }
     }
     AssetPostprocessingInternal.m_ImportProcessors.Sort((IComparer) new AssetPostprocessingInternal.CompareAssetImportPriority());
     AssetPostprocessingInternal.PostprocessStack postprocessStack = new AssetPostprocessingInternal.PostprocessStack();
     postprocessStack.m_ImportProcessors = AssetPostprocessingInternal.m_ImportProcessors;
     if (AssetPostprocessingInternal.m_PostprocessStack == null)
     {
         AssetPostprocessingInternal.m_PostprocessStack = new ArrayList();
     }
     AssetPostprocessingInternal.m_PostprocessStack.Add((object)postprocessStack);
 }
 private static void InitPostprocessors(string pathName)
 {
     AssetPostprocessingInternal.m_ImportProcessors = new ArrayList();
     foreach (Type current in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
     {
         try
         {
             AssetPostprocessor assetPostprocessor = Activator.CreateInstance(current) as AssetPostprocessor;
             assetPostprocessor.assetPath = pathName;
             AssetPostprocessingInternal.m_ImportProcessors.Add(assetPostprocessor);
         }
         catch (MissingMethodException)
         {
             AssetPostprocessingInternal.LogPostProcessorMissingDefaultConstructor(current);
         }
         catch (Exception exception)
         {
             Debug.LogException(exception);
         }
     }
     AssetPostprocessingInternal.m_ImportProcessors.Sort(new AssetPostprocessingInternal.CompareAssetImportPriority());
     AssetPostprocessingInternal.PostprocessStack postprocessStack = new AssetPostprocessingInternal.PostprocessStack();
     postprocessStack.m_ImportProcessors = AssetPostprocessingInternal.m_ImportProcessors;
     if (AssetPostprocessingInternal.m_PostprocessStack == null)
     {
         AssetPostprocessingInternal.m_PostprocessStack = new ArrayList();
     }
     AssetPostprocessingInternal.m_PostprocessStack.Add(postprocessStack);
 }
        static uint[] GetAudioProcessorVersions()
        {
            List <uint> versions = new List <uint>();

            foreach (var assetPostprocessorClass in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
            {
                try
                {
                    var  inst = Activator.CreateInstance(assetPostprocessorClass) as AssetPostprocessor;
                    var  type = inst.GetType();
                    bool hasPreProcessMethod  = type.GetMethod("OnPreprocessAudio", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null;
                    bool hasPostProcessMethod = type.GetMethod("OnPostprocessAudio", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) != null;
                    uint version = inst.GetVersion();
                    if (version != 0 && (hasPreProcessMethod || hasPostProcessMethod))
                    {
                        versions.Add(version);
                    }
                }
                catch (MissingMethodException)
                {
                    LogPostProcessorMissingDefaultConstructor(assetPostprocessorClass);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            return(versions.ToArray());
        }
 private static IEnumerable <MethodInfo> AllPostProcessorMethodsNamed(string callbackName)
 {
     return(from assetPostprocessorClass in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor))
            select assetPostprocessorClass.GetMethod(callbackName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) into method
                where method != null
            select method);
 }
        private static uint[] GetAudioProcessorVersions()
        {
            List <uint> list = new List <uint>();

            foreach (Type current in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
            {
                try
                {
                    AssetPostprocessor assetPostprocessor = Activator.CreateInstance(current) as AssetPostprocessor;
                    Type type    = assetPostprocessor.GetType();
                    bool flag    = type.GetMethod("OnPreprocessAudio", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null;
                    bool flag2   = type.GetMethod("OnPostprocessAudio", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null;
                    uint version = assetPostprocessor.GetVersion();
                    if (version != 0u && (flag || flag2))
                    {
                        list.Add(version);
                    }
                }
                catch (MissingMethodException)
                {
                    AssetPostprocessingInternal.LogPostProcessorMissingDefaultConstructor(current);
                }
                catch (Exception exception)
                {
                    Debug.LogException(exception);
                }
            }
            return(list.ToArray());
        }
        private static MaterialPropertyDrawer GetShaderPropertyDrawer(string attrib, out bool isDecorator)
        {
            isDecorator = false;
            string str      = attrib;
            string argsText = string.Empty;
            Match  match    = Regex.Match(attrib, @"(\w+)\s*\((.*)\)");

            if (match.Success)
            {
                str      = match.Groups[1].Value;
                argsText = match.Groups[2].Value.Trim();
            }
            foreach (System.Type type in EditorAssemblies.SubclassesOf(typeof(MaterialPropertyDrawer)))
            {
                if (((type.Name == str) || (type.Name == (str + "Drawer"))) || (((type.Name == ("Material" + str + "Drawer")) || (type.Name == (str + "Decorator"))) || (type.Name == ("Material" + str + "Decorator"))))
                {
                    try
                    {
                        isDecorator = type.Name.EndsWith("Decorator");
                        return(CreatePropertyDrawer(type, argsText));
                    }
                    catch (Exception)
                    {
                        object[] args = new object[] { str, argsText };
                        Debug.LogWarningFormat("Failed to create material drawer {0} with arguments '{1}'", args);
                        return(null);
                    }
                }
            }
            return(null);
        }
Beispiel #7
0
 static Type[] GetCachedAssetPostprocessorClasses()
 {
     if (m_PostprocessorClasses == null)
     {
         m_PostprocessorClasses = EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)).ToArray();
     }
     return(m_PostprocessorClasses);
 }
 private static IEnumerable <MethodInfo> AllPostProcessorMethodsNamed(string callbackName)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: reference to a compiler-generated method
     return(EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)).Select <System.Type, MethodInfo>(new Func <System.Type, MethodInfo>(new AssetPostprocessingInternal.\u003CAllPostProcessorMethodsNamed\u003Ec__AnonStorey31()
     {
         callbackName = callbackName
     }.\u003C\u003Em__46)).Where <MethodInfo>((Func <MethodInfo, bool>)(method => method != null)));
 }
        static void PostprocessAssetbundleNameChanged(string assetPAth, string prevoiusAssetBundleName, string newAssetBundleName)
        {
            object[] args = { assetPAth, prevoiusAssetBundleName, newAssetBundleName };

            foreach (var assetPostprocessorClass in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
            {
                var assetPostprocessor = Activator.CreateInstance(assetPostprocessorClass) as AssetPostprocessor;
                AttributeHelper.InvokeMemberIfAvailable(assetPostprocessor, "OnPostprocessAssetbundleNameChanged", args);
            }
        }
 static ArrayList GetCachedAssetPostprocessorClasses()
 {
     if (m_PostprocessorClasses == null)
     {
         m_PostprocessorClasses = new ArrayList();
         foreach (var type in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
         {
             m_PostprocessorClasses.Add(type);
         }
     }
     return(m_PostprocessorClasses);
 }
 private static ArrayList GetCachedAssetPostprocessorClasses()
 {
     if (AssetPostprocessingInternal.m_PostprocessorClasses == null)
     {
         AssetPostprocessingInternal.m_PostprocessorClasses = new ArrayList();
         foreach (Type current in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
         {
             AssetPostprocessingInternal.m_PostprocessorClasses.Add(current);
         }
     }
     return(AssetPostprocessingInternal.m_PostprocessorClasses);
 }
Beispiel #12
0
 internal static void CallOnGeneratedCSProjectFiles()
 {
     foreach (Type current in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
     {
         MethodInfo method = current.GetMethod("OnGeneratedCSProjectFiles", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
         if (method != null)
         {
             object[] parameters = new object[0];
             method.Invoke(null, parameters);
         }
     }
 }
 private static void PostprocessAssetbundleNameChanged(string assetPAth, string prevoiusAssetBundleName, string newAssetBundleName)
 {
     object[] args = new object[3]
     {
         (object)assetPAth,
         (object)prevoiusAssetBundleName,
         (object)newAssetBundleName
     };
     foreach (System.Type type in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
     {
         AttributeHelper.InvokeMemberIfAvailable((object)(Activator.CreateInstance(type) as AssetPostprocessor), "OnPostprocessAssetbundleNameChanged", args);
     }
 }
Beispiel #14
0
        private void RegisterCustomModules()
        {
            Type typeFromHandle = typeof(SpriteEditorModuleBase);

            foreach (Type current in EditorAssemblies.SubclassesOf(typeFromHandle))
            {
                if (!current.IsAbstract)
                {
                    bool flag = false;
                    foreach (SpriteEditorModuleBase current2 in this.m_AllRegisteredModules)
                    {
                        if (current2.GetType() == current)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        Type[]          types       = new Type[0];
                        ConstructorInfo constructor = current.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, CallingConventions.HasThis, types, null);
                        if (constructor != null)
                        {
                            try
                            {
                                SpriteEditorModuleBase spriteEditorModuleBase = constructor.Invoke(new object[0]) as SpriteEditorModuleBase;
                                if (spriteEditorModuleBase != null)
                                {
                                    spriteEditorModuleBase.spriteEditor = this;
                                    this.RegisterModule(spriteEditorModuleBase);
                                }
                            }
                            catch (Exception ex)
                            {
                                Debug.LogWarning(string.Concat(new object[]
                                {
                                    "Unable to instantiate custom module ",
                                    current.FullName,
                                    ". Exception:",
                                    ex
                                }));
                            }
                        }
                        else
                        {
                            Debug.LogWarning(current.FullName + " does not have a parameterless constructor");
                        }
                    }
                }
            }
        }
 private static void PostprocessAssetbundleNameChanged(string assetPAth, string prevoiusAssetBundleName, string newAssetBundleName)
 {
     object[] args = new object[]
     {
         assetPAth,
         prevoiusAssetBundleName,
         newAssetBundleName
     };
     foreach (Type current in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
     {
         AssetPostprocessor target = Activator.CreateInstance(current) as AssetPostprocessor;
         AttributeHelper.InvokeMemberIfAvailable(target, "OnPostprocessAssetbundleNameChanged", args);
     }
 }
        // Postprocess on all assets once an automatic import has completed
        static void PostprocessAllAssets(string[] importedAssets, string[] addedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPathAssets)
        {
            object[] args = { importedAssets, deletedAssets, movedAssets, movedFromPathAssets };
            foreach (var assetPostprocessorClass in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
            {
                MethodInfo method = assetPostprocessorClass.GetMethod("OnPostprocessAllAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (method != null)
                {
                    method.Invoke(null, args);
                }
            }

            ///@TODO: we need addedAssets for SyncVS. Make this into a proper API and write tests
            SyncVS.PostprocessSyncProject(importedAssets, addedAssets, deletedAssets, movedAssets, movedFromPathAssets);
        }
Beispiel #17
0
        void RegisterCustomModules()
        {
            var type = typeof(SpriteEditorModuleBase);

            foreach (var moduleClassType in EditorAssemblies.SubclassesOf(type))
            {
                if (!moduleClassType.IsAbstract)
                {
                    bool moduleFound = false;
                    foreach (var module in m_AllRegisteredModules)
                    {
                        if (module.GetType() == moduleClassType)
                        {
                            moduleFound = true;
                            break;
                        }
                    }
                    if (!moduleFound)
                    {
                        var constructorType = new Type[0];
                        // Get the public instance constructor that takes ISpriteEditorModule parameter.
                        var constructorInfoObj = moduleClassType.GetConstructor(
                            BindingFlags.Instance | BindingFlags.Public, null,
                            CallingConventions.HasThis, constructorType, null);
                        if (constructorInfoObj != null)
                        {
                            try
                            {
                                var newInstance = constructorInfoObj.Invoke(new object[0]) as SpriteEditorModuleBase;
                                if (newInstance != null)
                                {
                                    newInstance.spriteEditor = this;
                                    RegisterModule(newInstance);
                                }
                            }
                            catch (Exception ex)
                            {
                                Debug.LogWarning("Unable to instantiate custom module " + moduleClassType.FullName + ". Exception:" + ex);
                            }
                        }
                        else
                        {
                            Debug.LogWarning(moduleClassType.FullName + " does not have a parameterless constructor");
                        }
                    }
                }
            }
        }
        private static MaterialPropertyDrawer GetShaderPropertyDrawer(string attrib, out bool isDecorator)
        {
            isDecorator = false;
            string str      = attrib;
            string argsText = string.Empty;
            Match  match    = Regex.Match(attrib, "(\\w+)\\s*\\((.*)\\)");

            if (match.Success)
            {
                str      = match.Groups[1].Value;
                argsText = match.Groups[2].Value.Trim();
            }
            foreach (System.Type klass in EditorAssemblies.SubclassesOf(typeof(MaterialPropertyDrawer)))
            {
                if (!(klass.Name == str))
                {
                    if (!(klass.Name == str + "Drawer"))
                    {
                        if (!(klass.Name == "Material" + str + "Drawer"))
                        {
                            if (!(klass.Name == str + "Decorator"))
                            {
                                if (!(klass.Name == "Material" + str + "Decorator"))
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }
                try
                {
                    isDecorator = klass.Name.EndsWith("Decorator");
                    return(MaterialPropertyHandler.CreatePropertyDrawer(klass, argsText));
                }
                catch (Exception ex)
                {
                    Debug.LogWarningFormat("Failed to create material drawer {0} with arguments '{1}'", new object[2]
                    {
                        (object)str,
                        (object)argsText
                    });
                    return((MaterialPropertyDrawer)null);
                }
            }
            return((MaterialPropertyDrawer)null);
        }
Beispiel #19
0
        // Called on demand
        private static void BuildDrawerTypeForTypeDictionary()
        {
            s_DrawerTypeForType = new Dictionary <Type, DrawerKeySet>();

            var loadedTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => AssemblyHelper.GetTypesFromAssembly(x)).ToArray();

            foreach (var type in EditorAssemblies.SubclassesOf(typeof(GUIDrawer)))
            {
                //Debug.Log("Drawer: " + type);
                object[] attrs = type.GetCustomAttributes(typeof(CustomPropertyDrawer), true);
                foreach (CustomPropertyDrawer editor in attrs)
                {
                    //Debug.Log("Base type: " + editor.type);
                    s_DrawerTypeForType[editor.m_Type] = new DrawerKeySet()
                    {
                        drawer = type,
                        type   = editor.m_Type
                    };

                    if (!editor.m_UseForChildren)
                    {
                        continue;
                    }

                    var candidateTypes = loadedTypes.Where(x => x.IsSubclassOf(editor.m_Type));
                    foreach (var candidateType in candidateTypes)
                    {
                        //Debug.Log("Candidate Type: "+ candidateType);
                        if (s_DrawerTypeForType.ContainsKey(candidateType) &&
                            (editor.m_Type.IsAssignableFrom(s_DrawerTypeForType[candidateType].type)))
                        {
                            //  Debug.Log("skipping");
                            continue;
                        }

                        //Debug.Log("Setting");
                        s_DrawerTypeForType[candidateType] = new DrawerKeySet()
                        {
                            drawer = type,
                            type   = editor.m_Type
                        };
                    }
                }
            }
        }
Beispiel #20
0
        private static MaterialPropertyDrawer GetShaderPropertyDrawer(string attrib, out bool isDecorator)
        {
            isDecorator = false;
            string str      = attrib;
            string argsText = string.Empty;
            Match  match    = Regex.Match(attrib, @"(\w+)\s*\((.*)\)");

            if (match.Success)
            {
                str      = match.Groups[1].Value;
                argsText = match.Groups[2].Value.Trim();
            }
            IEnumerator <System.Type> enumerator = EditorAssemblies.SubclassesOf(typeof(MaterialPropertyDrawer)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    System.Type current = enumerator.Current;
                    if (((current.Name == str) || (current.Name == (str + "Drawer"))) || (((current.Name == ("Material" + str + "Drawer")) || (current.Name == (str + "Decorator"))) || (current.Name == ("Material" + str + "Decorator"))))
                    {
                        try
                        {
                            isDecorator = current.Name.EndsWith("Decorator");
                            return(CreatePropertyDrawer(current, argsText));
                        }
                        catch (Exception)
                        {
                            object[] args = new object[] { str, argsText };
                            Debug.LogWarningFormat("Failed to create material drawer {0} with arguments '{1}'", args);
                            return(null);
                        }
                    }
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
            return(null);
        }
        private static MaterialPropertyDrawer GetShaderPropertyDrawer(string attrib, out bool isDecorator)
        {
            isDecorator = false;

            string className = attrib;
            string args      = string.Empty;
            Match  match     = Regex.Match(attrib, @"(\w+)\s*\((.*)\)");

            if (match.Success)
            {
                className = match.Groups[1].Value;
                args      = match.Groups[2].Value.Trim();
            }

            //Debug.Log ("looking for class " + className + " args '" + args + "'");
            foreach (var klass in EditorAssemblies.SubclassesOf(typeof(MaterialPropertyDrawer)))
            {
                // When you write [Foo] in shader, get Foo, FooDrawer, MaterialFooDrawer,
                // FooDecorator or MaterialFooDecorator class;
                // "kind of" similar to how C# does attributes.

                //@TODO: namespaces?
                if (klass.Name == className ||
                    klass.Name == className + "Drawer" ||
                    klass.Name == "Material" + className + "Drawer" ||
                    klass.Name == className + "Decorator" ||
                    klass.Name == "Material" + className + "Decorator")
                {
                    try
                    {
                        isDecorator = klass.Name.EndsWith("Decorator");
                        return(CreatePropertyDrawer(klass, args));
                    }
                    catch (Exception)
                    {
                        Debug.LogWarningFormat("Failed to create material drawer {0} with arguments '{1}'", className, args);
                        return(null);
                    }
                }
            }

            return(null);
        }
 private static void PostprocessAllAssets(string[] importedAssets, string[] addedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPathAssets)
 {
     object[] parameters = new object[]
     {
         importedAssets,
         deletedAssets,
         movedAssets,
         movedFromPathAssets
     };
     foreach (Type current in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
     {
         MethodInfo method = current.GetMethod("OnPostprocessAllAssets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
         if (method != null)
         {
             method.Invoke(null, parameters);
         }
     }
     SyncVS.PostprocessSyncProject(importedAssets, addedAssets, deletedAssets, movedAssets, movedFromPathAssets);
 }
 private static void BuildDrawerTypeForTypeDictionary()
 {
     ScriptAttributeUtility.s_DrawerTypeForType = new Dictionary <System.Type, ScriptAttributeUtility.DrawerKeySet>();
     System.Type[] array = ((IEnumerable <Assembly>)AppDomain.CurrentDomain.GetAssemblies()).SelectMany <Assembly, System.Type>((Func <Assembly, IEnumerable <System.Type> >)(x => (IEnumerable <System.Type>)AssemblyHelper.GetTypesFromAssembly(x))).ToArray <System.Type>();
     foreach (System.Type type in EditorAssemblies.SubclassesOf(typeof(GUIDrawer)))
     {
         object[] customAttributes = type.GetCustomAttributes(typeof(CustomPropertyDrawer), true);
         // ISSUE: object of a compiler-generated type is created
         // ISSUE: variable of a compiler-generated type
         ScriptAttributeUtility.\u003CBuildDrawerTypeForTypeDictionary\u003Ec__AnonStoreyB0 dictionaryCAnonStoreyB0 = new ScriptAttributeUtility.\u003CBuildDrawerTypeForTypeDictionary\u003Ec__AnonStoreyB0();
         foreach (CustomPropertyDrawer customPropertyDrawer in customAttributes)
         {
             // ISSUE: reference to a compiler-generated field
             dictionaryCAnonStoreyB0.editor = customPropertyDrawer;
             // ISSUE: reference to a compiler-generated field
             // ISSUE: reference to a compiler-generated field
             ScriptAttributeUtility.s_DrawerTypeForType[dictionaryCAnonStoreyB0.editor.m_Type] = new ScriptAttributeUtility.DrawerKeySet()
             {
                 drawer = type,
                 type   = dictionaryCAnonStoreyB0.editor.m_Type
             };
             // ISSUE: reference to a compiler-generated field
             if (dictionaryCAnonStoreyB0.editor.m_UseForChildren)
             {
                 // ISSUE: reference to a compiler-generated method
                 foreach (System.Type key in ((IEnumerable <System.Type>)array).Where <System.Type>(new Func <System.Type, bool>(dictionaryCAnonStoreyB0.\u003C\u003Em__1FB)))
                 {
                     // ISSUE: reference to a compiler-generated field
                     if (!ScriptAttributeUtility.s_DrawerTypeForType.ContainsKey(key) || !dictionaryCAnonStoreyB0.editor.m_Type.IsAssignableFrom(ScriptAttributeUtility.s_DrawerTypeForType[key].type))
                     {
                         // ISSUE: reference to a compiler-generated field
                         ScriptAttributeUtility.s_DrawerTypeForType[key] = new ScriptAttributeUtility.DrawerKeySet()
                         {
                             drawer = type,
                             type   = dictionaryCAnonStoreyB0.editor.m_Type
                         };
                     }
                 }
             }
         }
     }
 }
Beispiel #24
0
        private static MaterialPropertyDrawer GetShaderPropertyDrawer(string attrib, out bool isDecorator)
        {
            isDecorator = false;
            string text  = attrib;
            string text2 = string.Empty;
            Match  match = Regex.Match(attrib, "(\\w+)\\s*\\((.*)\\)");

            if (match.Success)
            {
                text  = match.Groups[1].Value;
                text2 = match.Groups[2].Value.Trim();
            }
            foreach (Type current in EditorAssemblies.SubclassesOf(typeof(MaterialPropertyDrawer)))
            {
                if (!(current.Name == text) && !(current.Name == text + "Drawer") && !(current.Name == "Material" + text + "Drawer") && !(current.Name == text + "Decorator"))
                {
                    if (!(current.Name == "Material" + text + "Decorator"))
                    {
                        continue;
                    }
                }
                try
                {
                    isDecorator = current.Name.EndsWith("Decorator");
                    MaterialPropertyDrawer result = MaterialPropertyHandler.CreatePropertyDrawer(current, text2);
                    return(result);
                }
                catch (Exception)
                {
                    Debug.LogWarningFormat("Failed to create material drawer {0} with arguments '{1}'", new object[]
                    {
                        text,
                        text2
                    });
                    MaterialPropertyDrawer result = null;
                    return(result);
                }
            }
            return(null);
        }
Beispiel #25
0
 private static void BuildDrawerTypeForTypeDictionary()
 {
     ScriptAttributeUtility.s_DrawerTypeForType = new Dictionary <Type, ScriptAttributeUtility.DrawerKeySet>();
     Type[] source = AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly x) => AssemblyHelper.GetTypesFromAssembly(x)).ToArray <Type>();
     foreach (Type current in EditorAssemblies.SubclassesOf(typeof(GUIDrawer)))
     {
         object[]             customAttributes = current.GetCustomAttributes(typeof(CustomPropertyDrawer), true);
         object[]             array            = customAttributes;
         CustomPropertyDrawer editor;
         for (int i = 0; i < array.Length; i++)
         {
             editor = (CustomPropertyDrawer)array[i];
             ScriptAttributeUtility.s_DrawerTypeForType[editor.m_Type] = new ScriptAttributeUtility.DrawerKeySet
             {
                 drawer = current,
                 type   = editor.m_Type
             };
             if (editor.m_UseForChildren)
             {
                 IEnumerable <Type> enumerable =
                     from x in source
                     where x.IsSubclassOf(editor.m_Type)
                     select x;
                 foreach (Type current2 in enumerable)
                 {
                     if (!ScriptAttributeUtility.s_DrawerTypeForType.ContainsKey(current2) || !editor.m_Type.IsAssignableFrom(ScriptAttributeUtility.s_DrawerTypeForType[current2].type))
                     {
                         ScriptAttributeUtility.s_DrawerTypeForType[current2] = new ScriptAttributeUtility.DrawerKeySet
                         {
                             drawer = current,
                             type   = editor.m_Type
                         };
                     }
                 }
             }
         }
     }
 }
Beispiel #26
0
        protected Type[] GetPaneTypes()
        {
            const string k_PaneTypesSectionName = "pane_types";

            if (!ModeService.HasSection(ModeService.currentIndex, k_PaneTypesSectionName))
            {
                return new[]
                       {
                           typeof(SceneView),
                           typeof(GameView),
                           typeof(InspectorWindow),
                           typeof(SceneHierarchyWindow),
                           typeof(ProjectBrowser),
                           typeof(ProfilerWindow),
                           typeof(AnimationWindow)
                       }
            }
            ;

            var modePaneTypes = ModeService.GetModeDataSectionList <string>(ModeService.currentIndex, k_PaneTypesSectionName).ToArray();

            return(EditorAssemblies.SubclassesOf(typeof(EditorWindow)).Where(t => modePaneTypes.Any(mpt => t.Name.EndsWith(mpt))).ToArray());
        }
        private static uint[] GetMeshProcessorVersions()
        {
            List <uint> uintList = new List <uint>();

            foreach (System.Type type1 in EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)))
            {
                try
                {
                    AssetPostprocessor instance = Activator.CreateInstance(type1) as AssetPostprocessor;
                    System.Type        type2    = instance.GetType();
                    bool flag1   = type2.GetMethod("OnPreprocessModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null;
                    bool flag2   = type2.GetMethod("OnProcessMeshAssingModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null;
                    bool flag3   = type2.GetMethod("OnPostprocessModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null;
                    uint version = instance.GetVersion();
                    if ((int)version != 0)
                    {
                        if (!flag1 && !flag2)
                        {
                            if (!flag3)
                            {
                                continue;
                            }
                        }
                        uintList.Add(version);
                    }
                }
                catch (MissingMethodException ex)
                {
                    AssetPostprocessingInternal.LogPostProcessorMissingDefaultConstructor(type1);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
            return(uintList.ToArray());
        }
 private static IEnumerable <MethodInfo> AllPostProcessorMethodsNamed(string callbackName)
 {
     return(EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)).Select(assetPostprocessorClass => assetPostprocessorClass.GetMethod(callbackName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)).Where(method => method != null));
 }