コード例 #1
0
        internal static void InitializeBuildCallbacks(bool findBuildProcessors, bool findSceneProcessors)
        {
            BuildPipelineInterfaces.CleanupBuildCallbacks();
            HashSet <string> hashSet = new HashSet <string>();

            hashSet.Add("UnityEditor");
            hashSet.Add("UnityEngine.UI");
            hashSet.Add("Unity.PackageManager");
            hashSet.Add("UnityEngine.Networking");
            hashSet.Add("nunit.framework");
            hashSet.Add("UnityEditor.TreeEditor");
            hashSet.Add("UnityEditor.Graphs");
            hashSet.Add("UnityEditor.UI");
            hashSet.Add("UnityEditor.TestRunner");
            hashSet.Add("UnityEngine.TestRunner");
            hashSet.Add("UnityEngine.HoloLens");
            hashSet.Add("SyntaxTree.VisualStudio.Unity.Bridge");
            hashSet.Add("UnityEditor.Android.Extensions");
            BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

            Type[] expectedArguments = new Type[]
            {
                typeof(BuildTarget),
                typeof(string)
            };
            for (int i = 0; i < EditorAssemblies.loadedAssemblies.Length; i++)
            {
                Assembly assembly = EditorAssemblies.loadedAssemblies[i];
                bool     flag     = !hashSet.Contains(assembly.FullName.Substring(0, assembly.FullName.IndexOf(',')));
                Type[]   array    = null;
                try
                {
                    array = assembly.GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    array = ex.Types;
                }
                for (int j = 0; j < array.Length; j++)
                {
                    Type type = array[j];
                    if (type != null)
                    {
                        object obj   = null;
                        bool   flag2 = false;
                        if (findBuildProcessors)
                        {
                            flag2 = typeof(IOrderedCallback).IsAssignableFrom(type);
                            if (flag2)
                            {
                                if (!type.IsInterface && typeof(IPreprocessBuild).IsAssignableFrom(type) && type != typeof(BuildPipelineInterfaces.AttributeCallbackWrapper))
                                {
                                    obj = Activator.CreateInstance(type);
                                    BuildPipelineInterfaces.AddToList <IPreprocessBuild>(obj, ref BuildPipelineInterfaces.buildPreprocessors);
                                }
                                if (!type.IsInterface && typeof(IPostprocessBuild).IsAssignableFrom(type) && type != typeof(BuildPipelineInterfaces.AttributeCallbackWrapper))
                                {
                                    obj = ((obj != null) ? obj : Activator.CreateInstance(type));
                                    BuildPipelineInterfaces.AddToList <IPostprocessBuild>(obj, ref BuildPipelineInterfaces.buildPostprocessors);
                                }
                            }
                        }
                        if (findSceneProcessors)
                        {
                            if (!findBuildProcessors || flag2)
                            {
                                if (!type.IsInterface && typeof(IProcessScene).IsAssignableFrom(type) && type != typeof(BuildPipelineInterfaces.AttributeCallbackWrapper))
                                {
                                    obj = ((obj != null) ? obj : Activator.CreateInstance(type));
                                    BuildPipelineInterfaces.AddToList <IProcessScene>(obj, ref BuildPipelineInterfaces.sceneProcessors);
                                }
                            }
                        }
                        if (flag)
                        {
                            MethodInfo[] methods = type.GetMethods(bindingAttr);
                            for (int k = 0; k < methods.Length; k++)
                            {
                                MethodInfo methodInfo = methods[k];
                                if (!methodInfo.IsSpecialName)
                                {
                                    if (findBuildProcessors && BuildPipelineInterfaces.ValidateMethod(methodInfo, typeof(PostProcessBuildAttribute), expectedArguments))
                                    {
                                        BuildPipelineInterfaces.AddToList <IPostprocessBuild>(new BuildPipelineInterfaces.AttributeCallbackWrapper(methodInfo), ref BuildPipelineInterfaces.buildPostprocessors);
                                    }
                                    if (findSceneProcessors && BuildPipelineInterfaces.ValidateMethod(methodInfo, typeof(PostProcessSceneAttribute), Type.EmptyTypes))
                                    {
                                        BuildPipelineInterfaces.AddToList <IProcessScene>(new BuildPipelineInterfaces.AttributeCallbackWrapper(methodInfo), ref BuildPipelineInterfaces.sceneProcessors);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (BuildPipelineInterfaces.buildPreprocessors != null)
            {
                List <IPreprocessBuild> arg_379_0 = BuildPipelineInterfaces.buildPreprocessors;
                if (BuildPipelineInterfaces.< > f__mg$cache0 == null)
                {
                    BuildPipelineInterfaces.< > f__mg$cache0 = new Comparison <IPreprocessBuild>(BuildPipelineInterfaces.CompareICallbackOrder);
                }
                arg_379_0.Sort(BuildPipelineInterfaces.< > f__mg$cache0);
            }
            if (BuildPipelineInterfaces.buildPostprocessors != null)
            {
                List <IPostprocessBuild> arg_3AA_0 = BuildPipelineInterfaces.buildPostprocessors;
                if (BuildPipelineInterfaces.< > f__mg$cache1 == null)
                {
                    BuildPipelineInterfaces.< > f__mg$cache1 = new Comparison <IPostprocessBuild>(BuildPipelineInterfaces.CompareICallbackOrder);
                }
                arg_3AA_0.Sort(BuildPipelineInterfaces.< > f__mg$cache1);
            }
            if (BuildPipelineInterfaces.sceneProcessors != null)
            {
                List <IProcessScene> arg_3DB_0 = BuildPipelineInterfaces.sceneProcessors;
                if (BuildPipelineInterfaces.< > f__mg$cache2 == null)
                {
                    BuildPipelineInterfaces.< > f__mg$cache2 = new Comparison <IProcessScene>(BuildPipelineInterfaces.CompareICallbackOrder);
                }
                arg_3DB_0.Sort(BuildPipelineInterfaces.< > f__mg$cache2);
            }
        }
コード例 #2
0
 internal static void InitializeBuildCallbacks(BuildPipelineInterfaces.BuildCallbacks findFlags)
 {
     if (findFlags != BuildPipelineInterfaces.previousFlags)
     {
         BuildPipelineInterfaces.previousFlags = findFlags;
         BuildPipelineInterfaces.CleanupBuildCallbacks();
         bool   flag              = (findFlags & BuildPipelineInterfaces.BuildCallbacks.BuildProcessors) == BuildPipelineInterfaces.BuildCallbacks.BuildProcessors;
         bool   flag2             = (findFlags & BuildPipelineInterfaces.BuildCallbacks.SceneProcessors) == BuildPipelineInterfaces.BuildCallbacks.SceneProcessors;
         bool   flag3             = (findFlags & BuildPipelineInterfaces.BuildCallbacks.BuildTargetProcessors) == BuildPipelineInterfaces.BuildCallbacks.BuildTargetProcessors;
         Type[] expectedArguments = new Type[]
         {
             typeof(BuildTarget),
             typeof(string)
         };
         foreach (Type current in EditorAssemblies.GetAllTypesWithInterface <IOrderedCallback>())
         {
             if (!current.IsAbstract && !current.IsInterface)
             {
                 object obj = null;
                 if (flag)
                 {
                     if (BuildPipelineInterfaces.ValidateType <IPreprocessBuild>(current))
                     {
                         BuildPipelineInterfaces.AddToList <IPreprocessBuild>(obj = Activator.CreateInstance(current), ref BuildPipelineInterfaces.buildPreprocessors);
                     }
                     if (BuildPipelineInterfaces.ValidateType <IPostprocessBuild>(current))
                     {
                         BuildPipelineInterfaces.AddToList <IPostprocessBuild>(obj = ((obj != null) ? obj : Activator.CreateInstance(current)), ref BuildPipelineInterfaces.buildPostprocessors);
                     }
                 }
                 if (flag2 && BuildPipelineInterfaces.ValidateType <IProcessScene>(current))
                 {
                     BuildPipelineInterfaces.AddToList <IProcessScene>(obj = ((obj != null) ? obj : Activator.CreateInstance(current)), ref BuildPipelineInterfaces.sceneProcessors);
                 }
                 if (flag3 && BuildPipelineInterfaces.ValidateType <IActiveBuildTargetChanged>(current))
                 {
                     BuildPipelineInterfaces.AddToList <IActiveBuildTargetChanged>((obj != null) ? obj : Activator.CreateInstance(current), ref BuildPipelineInterfaces.buildTargetProcessors);
                 }
             }
         }
         if (flag)
         {
             foreach (MethodInfo current2 in EditorAssemblies.GetAllMethodsWithAttribute <PostProcessBuildAttribute>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
             {
                 if (BuildPipelineInterfaces.ValidateMethod <PostProcessBuildAttribute>(current2, expectedArguments))
                 {
                     BuildPipelineInterfaces.AddToList <IPostprocessBuild>(new BuildPipelineInterfaces.AttributeCallbackWrapper(current2), ref BuildPipelineInterfaces.buildPostprocessors);
                 }
             }
         }
         if (flag2)
         {
             foreach (MethodInfo current3 in EditorAssemblies.GetAllMethodsWithAttribute <PostProcessSceneAttribute>(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
             {
                 if (BuildPipelineInterfaces.ValidateMethod <PostProcessSceneAttribute>(current3, Type.EmptyTypes))
                 {
                     BuildPipelineInterfaces.AddToList <IProcessScene>(new BuildPipelineInterfaces.AttributeCallbackWrapper(current3), ref BuildPipelineInterfaces.sceneProcessors);
                 }
             }
         }
         if (BuildPipelineInterfaces.buildPreprocessors != null)
         {
             List <IPreprocessBuild> arg_263_0 = BuildPipelineInterfaces.buildPreprocessors;
             if (BuildPipelineInterfaces.< > f__mg$cache0 == null)
             {
                 BuildPipelineInterfaces.< > f__mg$cache0 = new Comparison <IPreprocessBuild>(BuildPipelineInterfaces.CompareICallbackOrder);
             }
             arg_263_0.Sort(BuildPipelineInterfaces.< > f__mg$cache0);
         }
         if (BuildPipelineInterfaces.buildPostprocessors != null)
         {
             List <IPostprocessBuild> arg_294_0 = BuildPipelineInterfaces.buildPostprocessors;
             if (BuildPipelineInterfaces.< > f__mg$cache1 == null)
             {
                 BuildPipelineInterfaces.< > f__mg$cache1 = new Comparison <IPostprocessBuild>(BuildPipelineInterfaces.CompareICallbackOrder);
             }
             arg_294_0.Sort(BuildPipelineInterfaces.< > f__mg$cache1);
         }
         if (BuildPipelineInterfaces.buildTargetProcessors != null)
         {
             List <IActiveBuildTargetChanged> arg_2C5_0 = BuildPipelineInterfaces.buildTargetProcessors;
             if (BuildPipelineInterfaces.< > f__mg$cache2 == null)
             {
                 BuildPipelineInterfaces.< > f__mg$cache2 = new Comparison <IActiveBuildTargetChanged>(BuildPipelineInterfaces.CompareICallbackOrder);
             }
             arg_2C5_0.Sort(BuildPipelineInterfaces.< > f__mg$cache2);
         }
         if (BuildPipelineInterfaces.sceneProcessors != null)
         {
             List <IProcessScene> arg_2F6_0 = BuildPipelineInterfaces.sceneProcessors;
             if (BuildPipelineInterfaces.< > f__mg$cache3 == null)
             {
                 BuildPipelineInterfaces.< > f__mg$cache3 = new Comparison <IProcessScene>(BuildPipelineInterfaces.CompareICallbackOrder);
             }
             arg_2F6_0.Sort(BuildPipelineInterfaces.< > f__mg$cache3);
         }
     }
 }