Skip to content

Commit 724027a

Browse files
Merge pull request #962 from StephenHodgson/HTK-QualitySettings
Quality Settings regression fix.
2 parents 06211c2 + 782d1fd commit 724027a

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

Assets/HoloToolkit/Utilities/Scripts/Editor/ProjectSettingsWindow.cs

+25-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using System;
5+
using System.IO;
6+
using System.Text.RegularExpressions;
57
using UnityEditor;
68
using UnityEngine;
79

@@ -78,21 +80,35 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
7880

7981
if (Values[ProjectSetting.WsaFastestQuality])
8082
{
81-
int settingId = -1;
8283
for (var i = 0; i < QualitySettings.names.Length; i++)
8384
{
84-
if (QualitySettings.names[i].Equals("Fastest"))
85-
{
86-
QualitySettings.SetQualityLevel(i);
87-
settingId = i;
88-
break;
89-
}
85+
QualitySettings.DecreaseLevel(true);
9086
}
9187

92-
if (settingId < 0)
88+
int currentQualityLevel = QualitySettings.GetQualityLevel();
89+
Debug.Log("Current Quality Level: " + currentQualityLevel);
90+
91+
// HACK: Edits QualitySettings.asset Directly
92+
// TODO: replace with friendlier version that uses built in APIs when Unity fixes or makes available.
93+
// See: http://answers.unity3d.com/questions/886160/how-do-i-change-qualitysetting-for-my-platform-fro.html
94+
try
9395
{
94-
Debug.LogWarning("Failed to find Quality Setting 'Fastest'");
96+
// Find the WSA element under the platform quality list and replace it's value with the current level.
97+
string settingsPath = "ProjectSettings/QualitySettings.asset";
98+
string matchPattern = @"(m_PerPlatformDefaultQuality.*Windows Store Apps:) (\d+)";
99+
string replacePattern = @"$1 " + currentQualityLevel;
100+
101+
string settings = File.ReadAllText(settingsPath);
102+
settings = Regex.Replace(settings, matchPattern, replacePattern, RegexOptions.Singleline);
103+
104+
File.WriteAllText(settingsPath, settings);
95105
}
106+
catch (Exception e)
107+
{
108+
Debug.LogException(e);
109+
}
110+
111+
AssetDatabase.Refresh();
96112
}
97113

98114
UnityEditorInternal.VR.VREditor.SetVREnabledOnTargetGroup(BuildTargetGroup.WSA, Values[ProjectSetting.WsaEnableVR]);

ProjectSettings/QualitySettings.asset

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ QualitySettings:
182182
PSM: 5
183183
PSP2: 2
184184
Samsung TV: 2
185-
Standalone: 0
185+
Standalone: 5
186186
Tizen: 2
187187
Web: 5
188188
WebGL: 3

0 commit comments

Comments
 (0)