コード例 #1
0
 static Type[] GetCachedAssetPostprocessorClasses()
 {
     if (m_PostprocessorClasses == null)
     {
         m_PostprocessorClasses = EditorAssemblies.SubclassesOf(typeof(AssetPostprocessor)).ToArray();
     }
     return(m_PostprocessorClasses);
 }
コード例 #2
0
 internal static IEnumerable <TReturnValue> CallMethodsWithAttribute <TReturnValue, TAttr>(params object[] arguments)
     where TAttr : Attribute
 {
     foreach (var method in EditorAssemblies.GetAllMethodsWithAttribute <TAttr>(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
     {
         yield return((TReturnValue)method.Invoke(null, arguments));
     }
 }
コード例 #3
0
 private static IEnumerable <Type> GetAllTypesWithInterface(Type interfaceType)
 {
     if (!interfaceType.IsInterface)
     {
         throw new ArgumentException(string.Format("Specified type {0} is not an interface.", interfaceType), "interfaceType");
     }
     return(EditorAssemblies.Internal_GetAllTypesWithInterface(interfaceType));
 }
コード例 #4
0
 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)));
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        private static int[] ProcessInitializeOnLoadAttributes()
        {
            List <int> list = null;

            Assembly[] loadedAssemblies = EditorAssemblies.loadedAssemblies;
            EditorAssemblies.m_TotalNumRuntimeInitializeMethods = 0;
            EditorAssemblies.m_RuntimeInitializeClassInfoList   = new List <RuntimeInitializeClassInfo>();
            for (int i = 0; i < loadedAssemblies.Length; i++)
            {
                int totalNumRuntimeInitializeMethods = EditorAssemblies.m_TotalNumRuntimeInitializeMethods;
                int count = EditorAssemblies.m_RuntimeInitializeClassInfoList.Count;
                try
                {
                    Type[] typesFromAssembly = AssemblyHelper.GetTypesFromAssembly(loadedAssemblies[i]);
                    Type[] array             = typesFromAssembly;
                    for (int j = 0; j < array.Length; j++)
                    {
                        Type type = array[j];
                        if (type.IsDefined(typeof(InitializeOnLoadAttribute), false))
                        {
                            EditorAssemblies.ProcessEditorInitializeOnLoad(type);
                        }
                        EditorAssemblies.ProcessStaticMethodAttributes(type);
                    }
                }
                catch (Exception exception)
                {
                    Debug.LogException(exception);
                    if (list == null)
                    {
                        list = new List <int>();
                    }
                    if (totalNumRuntimeInitializeMethods != EditorAssemblies.m_TotalNumRuntimeInitializeMethods)
                    {
                        EditorAssemblies.m_TotalNumRuntimeInitializeMethods = totalNumRuntimeInitializeMethods;
                    }
                    if (count != EditorAssemblies.m_RuntimeInitializeClassInfoList.Count)
                    {
                        EditorAssemblies.m_RuntimeInitializeClassInfoList.RemoveRange(count, EditorAssemblies.m_RuntimeInitializeClassInfoList.Count - count);
                    }
                    list.Add(i);
                }
            }
            int[] result;
            if (list == null)
            {
                result = null;
            }
            else
            {
                result = list.ToArray();
            }
            return(result);
        }
コード例 #7
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);
         }
     }
 }
コード例 #8
0
 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);
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
 private static void ProcessInitializeOnLoadAttributes()
 {
     EditorAssemblies.m_TotalNumRuntimeInitializeMethods = 0;
     EditorAssemblies.m_RuntimeInitializeClassInfoList   = new List <RuntimeInitializeClassInfo>();
     foreach (System.Type loadedType in EditorAssemblies.loadedTypes)
     {
         if (loadedType.IsDefined(typeof(InitializeOnLoadAttribute), false))
         {
             EditorAssemblies.ProcessEditorInitializeOnLoad(loadedType);
         }
         EditorAssemblies.ProcessStaticMethodAttributes(loadedType);
     }
 }
コード例 #12
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");
                        }
                    }
                }
            }
        }
コード例 #13
0
 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);
     }
 }
コード例 #14
0
        // 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);
        }
コード例 #15
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");
                        }
                    }
                }
            }
        }
コード例 #16
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();
            }
            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);
        }
コード例 #17
0
        private static void ProcessRuntimeInitializeOnLoad(MethodInfo method)
        {
            RuntimeInitializeLoadType item = RuntimeInitializeLoadType.AfterSceneLoad;

            object[] customAttributes = method.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), false);
            if (customAttributes != null && customAttributes.Length > 0)
            {
                item = ((RuntimeInitializeOnLoadMethodAttribute)customAttributes[0]).loadType;
            }
            EditorAssemblies.StoreRuntimeInitializeClassInfo(method.DeclaringType, new List <string>
            {
                method.Name
            }, new List <RuntimeInitializeLoadType>
            {
                item
            });
        }
コード例 #18
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
                        };
                    }
                }
            }
        }
コード例 #19
0
 private static int[] ProcessInitializeOnLoadAttributes()
 {
     EditorAssemblies.m_TotalNumRuntimeInitializeMethods = 0;
     EditorAssemblies.m_RuntimeInitializeClassInfoList   = new List <RuntimeInitializeClassInfo>();
     foreach (Type current in EditorAssemblies.GetAllTypesWithAttribute <InitializeOnLoadAttribute>())
     {
         EditorAssemblies.ProcessEditorInitializeOnLoad(current);
     }
     foreach (MethodInfo current2 in EditorAssemblies.GetAllMethodsWithAttribute <RuntimeInitializeOnLoadMethodAttribute>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
     {
         EditorAssemblies.ProcessRuntimeInitializeOnLoad(current2);
     }
     foreach (MethodInfo current3 in EditorAssemblies.GetAllMethodsWithAttribute <InitializeOnLoadMethodAttribute>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
     {
         EditorAssemblies.ProcessInitializeOnLoadMethod(current3);
     }
     return(null);
 }
コード例 #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);
        }
コード例 #21
0
 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);
 }
コード例 #22
0
        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);
        }
コード例 #23
0
        private static void ProcessStaticMethodAttributes(Type type)
        {
            List <string> list = null;
            List <RuntimeInitializeLoadType> list2 = null;

            MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            for (int i = 0; i < methods.GetLength(0); i++)
            {
                MethodInfo methodInfo = methods[i];
                if (Attribute.IsDefined(methodInfo, typeof(RuntimeInitializeOnLoadMethodAttribute)))
                {
                    RuntimeInitializeLoadType item = RuntimeInitializeLoadType.AfterSceneLoad;
                    object[] customAttributes      = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), false);
                    if (customAttributes != null && customAttributes.Length > 0)
                    {
                        item = ((RuntimeInitializeOnLoadMethodAttribute)customAttributes[0]).loadType;
                    }
                    if (list == null)
                    {
                        list  = new List <string>();
                        list2 = new List <RuntimeInitializeLoadType>();
                    }
                    list.Add(methodInfo.Name);
                    list2.Add(item);
                }
                if (Attribute.IsDefined(methodInfo, typeof(InitializeOnLoadMethodAttribute)))
                {
                    try
                    {
                        methodInfo.Invoke(null, null);
                    }
                    catch (TargetInvocationException ex)
                    {
                        Debug.LogError(ex.InnerException);
                    }
                }
            }
            if (list != null)
            {
                EditorAssemblies.StoreRuntimeInitializeClassInfo(type, list, list2);
            }
        }
コード例 #24
0
 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
                         };
                     }
                 }
             }
         }
     }
 }
コード例 #25
0
 static NativeFormatImporterUtility()
 {
     NativeFormatImporterUtility.s_RegisteredExtensionsByType = new Dictionary <Type, string[]>();
     foreach (Type current in EditorAssemblies.GetAllTypesWithAttribute <AssetFileNameExtensionAttribute>())
     {
         AssetFileNameExtensionAttribute assetFileNameExtensionAttribute = current.GetCustomAttributes(typeof(AssetFileNameExtensionAttribute), false)[0] as AssetFileNameExtensionAttribute;
         try
         {
             NativeFormatImporterUtility.RegisterExtensionForType(current, assetFileNameExtensionAttribute.preferredExtension, assetFileNameExtensionAttribute.otherExtensions.ToArray <string>());
         }
         catch (ArgumentException exception)
         {
             Debug.LogException(exception);
         }
         catch (NotSupportedException exception2)
         {
             Debug.LogException(exception2);
         }
     }
 }
 static NativeFormatImporterUtility()
 {
     foreach (var type in EditorAssemblies.GetAllTypesWithAttribute <AssetFileNameExtensionAttribute>())
     {
         var attr = type.GetCustomAttributes(typeof(AssetFileNameExtensionAttribute), false)[0]
                    as AssetFileNameExtensionAttribute;
         try
         {
             RegisterExtensionForType(type, attr.preferredExtension, attr.otherExtensions.ToArray());
         }
         catch (ArgumentException e)
         {
             Debug.LogException(e);
         }
         catch (NotSupportedException e)
         {
             Debug.LogException(e);
         }
     }
 }
コード例 #27
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);
        }
コード例 #28
0
        private ILightingExplorerExtension GetLightExplorerExtension(System.Type currentSRPType)
        {
            if (currentSRPType == null)
            {
                return(GetDefaultLightingExplorerExtension());
            }

            var extensionTypes = EditorAssemblies.GetAllTypesWithInterface <ILightingExplorerExtension>();

            foreach (System.Type extensionType in extensionTypes)
            {
                LightingExplorerExtensionAttribute attribute = System.Attribute.GetCustomAttribute(extensionType, typeof(LightingExplorerExtensionAttribute)) as LightingExplorerExtensionAttribute;
                if (attribute != null && attribute.renderPipelineType == currentSRPType)
                {
                    ILightingExplorerExtension extension = (ILightingExplorerExtension)System.Activator.CreateInstance(extensionType);
                    return(extension);
                }
            }

            // no light explorer extension found for current srp, return the default one
            return(GetDefaultLightingExplorerExtension());
        }
コード例 #29
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
                         };
                     }
                 }
             }
         }
     }
 }
コード例 #30
0
ファイル: HostView.cs プロジェクト: Achay009/UnityCsReference
        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());
        }