Ejemplo n.º 1
0
        private static UnityEditor.Compilation.Assembly FindUnityAssembly(string name, AssembliesType type)
        {
            UnityEditor.Compilation.Assembly   foundAssembly = null;
            UnityEditor.Compilation.Assembly[] assemblies    = CompilationPipeline.GetAssemblies(type);
            foreach (UnityEditor.Compilation.Assembly asm in assemblies)
            {
                if (asm.name == name)
                {
                    foundAssembly = asm;
                    break;
                }
            }

            return(foundAssembly);
        }
Ejemplo n.º 2
0
        private static bool IsReferenced(Assembly assembly)
        {
            // C# player referenced assemblies
            foreach (AssemblyName asmName in typeof(VRModule).Assembly.GetReferencedAssemblies())
            {
                if (assembly.GetName().Name == asmName.Name)
                {
                    return(true);
                }
            }

            // C# editor referenced assemblies
            foreach (AssemblyName asmName in typeof(VRModuleManagerEditor).Assembly.GetReferencedAssemblies())
            {
                if (assembly.GetName().Name == asmName.Name)
                {
                    return(true);
                }
            }

#if UNITY_2018_1_OR_NEWER
            // Unity player referenced assemblies
            UnityEditor.Compilation.Assembly playerUnityAsm = FindUnityAssembly(typeof(VRModule).Assembly.GetName().Name, AssembliesType.Player);
            if (playerUnityAsm != null)
            {
                foreach (UnityEditor.Compilation.Assembly asm in playerUnityAsm.assemblyReferences)
                {
                    if (assembly.GetName().Name == asm.name)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                Debug.LogWarning("Player assembly not found.");
            }

            // Unity editor referenced assemblies
            UnityEditor.Compilation.Assembly editorUnityAsm = FindUnityAssembly(typeof(VRModuleManagerEditor).Assembly.GetName().Name, AssembliesType.Editor);
            if (editorUnityAsm != null)
            {
                foreach (UnityEditor.Compilation.Assembly asm in editorUnityAsm.assemblyReferences)
                {
                    if (assembly.GetName().Name == asm.name)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                Debug.LogWarning("Editor assembly not found.");
            }
#elif UNITY_2017_3_OR_NEWER
            UnityEditor.Compilation.Assembly[] assemblies = CompilationPipeline.GetAssemblies();
            foreach (UnityEditor.Compilation.Assembly asm in assemblies)
            {
                if (assembly.GetName().Name == asm.name)
                {
                    return(true);
                }
            }
#endif

            return(false);
        }
        private static HashSet <string> GetReferencedAssemblyNameSet()
        {
            if (s_referencedAssemblyNameSet != null)
            {
                return(s_referencedAssemblyNameSet);
            }

            s_referencedAssemblyNameSet = new HashSet <string>();
            Assembly playerAssembly = typeof(VRModule).Assembly;
            Assembly editorAssembly = typeof(VRModuleManagerEditor).Assembly;

            // C# player referenced assemblies
            foreach (AssemblyName asmName in playerAssembly.GetReferencedAssemblies())
            {
                s_referencedAssemblyNameSet.Add(asmName.Name);
            }

            // C# editor referenced assemblies
            foreach (AssemblyName asmName in editorAssembly.GetReferencedAssemblies())
            {
                s_referencedAssemblyNameSet.Add(asmName.Name);
            }

#if UNITY_2018_1_OR_NEWER
            // Unity player referenced assemblies
            UnityEditor.Compilation.Assembly playerUnityAsm = FindUnityAssembly(playerAssembly.GetName().Name, AssembliesType.Player);
            if (playerUnityAsm != null)
            {
                foreach (UnityEditor.Compilation.Assembly asm in playerUnityAsm.assemblyReferences)
                {
                    s_referencedAssemblyNameSet.Add(asm.name);
                }
            }
            else
            {
                Debug.LogWarning("Player assembly not found.");
            }

            // Unity editor referenced assemblies
            UnityEditor.Compilation.Assembly editorUnityAsm = FindUnityAssembly(editorAssembly.GetName().Name, AssembliesType.Editor);
            if (editorUnityAsm != null)
            {
                foreach (UnityEditor.Compilation.Assembly asm in editorUnityAsm.assemblyReferences)
                {
                    s_referencedAssemblyNameSet.Add(asm.name);
                }
            }
            else
            {
                Debug.LogWarning("Editor assembly not found.");
            }
#elif UNITY_2017_3_OR_NEWER
            UnityEditor.Compilation.Assembly[] assemblies = CompilationPipeline.GetAssemblies();
            foreach (UnityEditor.Compilation.Assembly asm in assemblies)
            {
                s_referencedAssemblyNameSet.Add(asm.name);
            }
#endif

            return(s_referencedAssemblyNameSet);
        }