Esempio n. 1
0
        /// <summary>根据平台名称返回平台默认的品质级别</summary>
        private int GetDefaultQualityLevelWithPlatformName(QualityData qualityData, string platformName)
        {
            PlatformDefaultQuality[] platformDefaultQualities = qualityData.perPlatformDefaultQuality;
            int len = platformDefaultQualities.Length;

            for (int i = 0; i < len; i++)
            {
                PlatformDefaultQuality platformDefaultQuality = platformDefaultQualities[i];
                if (platformDefaultQuality.platform == platformName)
                {
                    return(platformDefaultQuality.qualityLevel);
                }
            }
            Debug.LogError("没找到" + platformName + "平台的默认品质级别,请确认平台:" + platformName + "是否存在。");
            return(-1);
        }
Esempio n. 2
0
        /// <summary>返回当前运行时平台的默认品质级别</summary>
        public int GetPlatformDefaultQualityLevel(QualityData qualityData)
        {
            RuntimePlatform platform = Application.platform;

            if (platform == RuntimePlatform.IPhonePlayer)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "iPhone"));
            }
            else if (platform == RuntimePlatform.Android)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "Android"));
            }
            else if (platform == RuntimePlatform.WebGLPlayer)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "WebGL"));
            }
            else if (platform == RuntimePlatform.WindowsPlayer || platform == RuntimePlatform.OSXPlayer || platform == RuntimePlatform.LinuxPlayer)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "Standalone"));
            }
            else if (platform == RuntimePlatform.PS4)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "PS4"));
            }
            else if (platform == RuntimePlatform.WSAPlayerARM || platform == RuntimePlatform.WSAPlayerX86 || platform == RuntimePlatform.WSAPlayerX64)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "Windows Store Apps"));
            }
            else if (platform == RuntimePlatform.XboxOne)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "XboxOne"));
            }
            else if (platform == RuntimePlatform.tvOS)
            {
                return(GetDefaultQualityLevelWithPlatformName(qualityData, "tvOS"));
            }
            //默认返回编辑器中高亮显示的品质设置
            return(qualityData.currentQuality);
        }
Esempio n. 3
0
        /// <summary>
        /// 导入项目的QualitySettings
        /// </summary>
        /// <param name="path">需要导入QualitySettings的项目路径</param>
        /// <param name="currentProjectTempPath">临时文件夹</param>
        /// <param name="projectName">需要导入项目名称</param>
        public override void Import(string path, string currentProjectTempPath, string projectName)
        {
            //需要导入的QualitySettings.asset的路径
            string settingsFilePath = path + "/ProjectSettings/QualitySettings.asset";

            StreamReader streamReader = new StreamReader(settingsFilePath, Encoding.UTF8);
            YamlStream   yaml         = new YamlStream();

            yaml.Load(streamReader);
            streamReader.Dispose();
            streamReader.Close();

            YamlNode        rootNode  = yaml.Documents[0].RootNode;
            YamlMappingNode firstNode = (YamlMappingNode)rootNode["QualitySettings"];

            QualityData qualityData = ScriptableObject.CreateInstance <QualityData>();

            //
            qualityData.currentQuality = int.Parse(firstNode["m_CurrentQuality"].ToString());
            //
            YamlSequenceNode       qualitySettingsNode = (YamlSequenceNode)firstNode["m_QualitySettings"];
            List <QualitySettings> qualitySettingsList = new List <QualitySettings>();

            foreach (var yamlNode in qualitySettingsNode)
            {
                var item = (YamlMappingNode)yamlNode;
                qualitySettingsList.Add(ReadQualitySettings(item));
            }
            qualityData.qualitySettings = qualitySettingsList.ToArray();
            //
            YamlMappingNode perPlatformDefaultQualityNode = (YamlMappingNode)firstNode["m_PerPlatformDefaultQuality"];

            qualityData.perPlatformDefaultQuality = ReadPlatformDefaultQuality(perPlatformDefaultQualityNode);
            //
            AssetDatabase.CreateAsset(qualityData, ProjectImporterEditor.resourcePath + "/" + projectName + "_qualityData.asset");
            AssetDatabase.Refresh();
        }