Esempio n. 1
0
 internal static string[] GetPrecompiledAssemblyNames(PrecompiledAssemblyProviderBase precompiledAssemblyProvider)
 {
     return(precompiledAssemblyProvider.GetPrecompiledAssemblies(true, EditorUserBuildSettings.activeBuildTargetGroup, EditorUserBuildSettings.activeBuildTarget)
            .Where(x => (x.Flags & sc.AssemblyFlags.UserAssembly) == sc.AssemblyFlags.UserAssembly)
            .Select(x => AssetPath.GetFileName(x.Path))
            .ToArray());
 }
        private void DrawPrecompiledReferenceListElement(Rect rect, int index, bool isactive, bool isfocused)
        {
            var precompiledReference = m_PrecompiledReferencesList.serializedProperty.GetArrayElementAtIndex(index);
            var nameProp             = precompiledReference.FindPropertyRelative("name");
            var pathProp             = precompiledReference.FindPropertyRelative("path");
            var fileNameProp         = precompiledReference.FindPropertyRelative("fileName");

            rect.height -= EditorGUIUtility.standardVerticalSpacing;
            GUIContent label = GUIContent.Temp(nameProp.stringValue);

            bool mixed = nameProp.hasMultipleDifferentValues;

            EditorGUI.showMixedValue = mixed;

            bool hasValue = !string.IsNullOrEmpty(pathProp.stringValue);

            if (!hasValue)
            {
                m_PrecompileReferenceListEntry.Insert(0, L10n.Tr("None"));

                if (m_PrecompileReferenceListEntry.Count == 1)
                {
                    label = EditorGUIUtility.TrTempContent("No possible references");
                }
                else
                {
                    label = EditorGUIUtility.TrTempContent("None");
                }
            }
            else
            {
                m_PrecompileReferenceListEntry.Insert(0, fileNameProp.stringValue);
            }

            int currentlySelectedIndex = 0;

            EditorGUI.BeginDisabled(!hasValue && !string.IsNullOrEmpty(nameProp.stringValue));
            int selectedIndex = EditorGUI.Popup(rect, label, currentlySelectedIndex, m_PrecompileReferenceListEntry.ToArray());

            EditorGUI.EndDisabled();


            if (selectedIndex > 0)
            {
                var selectedAssemblyName = m_PrecompileReferenceListEntry[selectedIndex];
                var assembly             = m_AssemblyProvider.GetPrecompiledAssemblies(
                    EditorScriptCompilationOptions.BuildingForEditor | EditorScriptCompilationOptions.BuildingWithAsserts,
                    EditorUserBuildSettings.activeBuildTargetGroup,
                    EditorUserBuildSettings.activeBuildTarget)
                                           .First(x => AssetPath.GetFileName(x.Path) == selectedAssemblyName);
                nameProp.stringValue     = selectedAssemblyName;
                pathProp.stringValue     = assembly.Path;
                fileNameProp.stringValue = AssetPath.GetFileName(assembly.Path);
            }

            m_PrecompileReferenceListEntry.RemoveAt(0);

            EditorGUI.showMixedValue = false;
        }
Esempio n. 3
0
        internal static string GetPrecompiledAssemblyPathFromAssemblyName(string assemblyName, PrecompiledAssemblyProviderBase precompiledAssemblyProvider)
        {
            var precompiledAssemblies = precompiledAssemblyProvider.GetPrecompiledAssemblies(true, EditorUserBuildSettings.activeBuildTargetGroup, EditorUserBuildSettings.activeBuildTarget);

            foreach (var assembly in precompiledAssemblies)
            {
                if ((assembly.Flags & sc.AssemblyFlags.UserAssembly) == sc.AssemblyFlags.UserAssembly && AssetPath.GetFileName(assembly.Path) == assemblyName)
                {
                    return(assembly.Path);
                }
            }
            return(null);
        }
        internal static string GetPrecompiledAssemblyPathFromAssemblyName(string assemblyName, PrecompiledAssemblyProviderBase precompiledAssemblyProvider, string[] extraScriptingDefines = null)
        {
            var precompiledAssemblies = precompiledAssemblyProvider.GetPrecompiledAssemblies(
                EditorScriptCompilationOptions.BuildingForEditor | EditorScriptCompilationOptions.BuildingWithAsserts,
                EditorUserBuildSettings.activeBuildTargetGroup,
                EditorUserBuildSettings.activeBuildTarget,
                extraScriptingDefines);

            foreach (var assembly in precompiledAssemblies)
            {
                if ((assembly.Flags & sc.AssemblyFlags.UserAssembly) == sc.AssemblyFlags.UserAssembly && AssetPath.GetFileName(assembly.Path) == assemblyName)
                {
                    return(assembly.Path);
                }
            }
            return(null);
        }
        internal static string[] GetPrecompiledAssemblyPaths(PrecompiledAssemblySources precompiledAssemblySources, PrecompiledAssemblyProviderBase precompiledAssemblyProvider, BuildTargetGroup buildTargetGroup, BuildTarget buildTarget)
        {
            HashSet <string> assemblyNames = new HashSet <string>();

            sc.AssemblyFlags flags = sc.AssemblyFlags.None;
            if ((precompiledAssemblySources & PrecompiledAssemblySources.SystemAssembly) != 0)
            {
                foreach (var a in MonoLibraryHelpers.GetSystemLibraryReferences(ApiCompatibilityLevel.NET_Unity_4_8))
                {
                    assemblyNames.Add(a);
                }
            }

            if ((precompiledAssemblySources & (PrecompiledAssemblySources.UnityEngine | precompiledAssemblySources & PrecompiledAssemblySources.UnityAssembly)) != 0)
            {
                flags |= sc.AssemblyFlags.UnityModule;
            }

            if ((precompiledAssemblySources & (PrecompiledAssemblySources.UnityEditor | precompiledAssemblySources & PrecompiledAssemblySources.UnityAssembly)) != 0)
            {
                flags |= sc.AssemblyFlags.EditorOnly;
            }

            if ((precompiledAssemblySources & PrecompiledAssemblySources.UserAssembly) != 0)
            {
                flags |= sc.AssemblyFlags.UserAssembly;
            }

            var precompiledAssemblies = precompiledAssemblyProvider.GetPrecompiledAssemblies(
                EditorScriptCompilationOptions.BuildingForEditor | EditorScriptCompilationOptions.BuildingWithAsserts,
                buildTargetGroup,
                buildTarget)
                                        .Concat(precompiledAssemblyProvider.GetUnityAssemblies(true, buildTarget));

            foreach (var a in precompiledAssemblies.Where(x => (x.Flags & flags) != 0))
            {
                assemblyNames.Add(a.Path);
            }

            return(assemblyNames.ToArray());
        }
Esempio n. 6
0
        internal static string[] GetPrecompiledAssemblyPaths(PrecompiledAssemblySources precompiledAssemblySources, PrecompiledAssemblyProviderBase precompiledAssemblyProvider)
        {
            HashSet <string> assemblyNames = new HashSet <string>();

            sc.AssemblyFlags flags = sc.AssemblyFlags.None;
            if ((precompiledAssemblySources & PrecompiledAssemblySources.SystemAssembly) != 0)
            {
                foreach (var a in MonoLibraryHelpers.GetSystemLibraryReferences(ApiCompatibilityLevel.NET_4_6, Scripting.ScriptCompilers.CSharpSupportedLanguage))
                {
                    assemblyNames.Add(a);
                }
            }

            if ((precompiledAssemblySources & PrecompiledAssemblySources.UnityEngine) != 0)
            {
                flags |= sc.AssemblyFlags.UnityModule;
            }

            if ((precompiledAssemblySources & PrecompiledAssemblySources.UnityEditor) != 0)
            {
                flags |= sc.AssemblyFlags.EditorOnly;
            }

            if ((precompiledAssemblySources & PrecompiledAssemblySources.UserAssembly) != 0)
            {
                flags |= sc.AssemblyFlags.UserAssembly;
            }

            var precompiledAssemblies = precompiledAssemblyProvider.GetPrecompiledAssemblies(true, EditorUserBuildSettings.activeBuildTargetGroup, EditorUserBuildSettings.activeBuildTarget).Concat(EditorCompilationInterface.Instance.GetUnityAssemblies());

            foreach (var a in precompiledAssemblies.Where(x => (x.Flags & flags) != 0))
            {
                assemblyNames.Add(a.Path);
            }

            return(assemblyNames.ToArray());
        }