Skip to content

Commit 4b6a302

Browse files
made all the dialog boxes one.
1 parent 6226772 commit 4b6a302

File tree

1 file changed

+21
-122
lines changed

1 file changed

+21
-122
lines changed

Assets/MixedRealityToolkit/_Core/Utilities/Editor/Setup/EnforceEditorSettings.cs

Lines changed: 21 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ public class EnforceEditorSettings
1616
{
1717
private const string SessionKey = "_MixedRealityToolkit_Editor_ShownSettingsPrompts";
1818
private const string BuildTargetGroupKey = "_MixedRealityToolkit_Editor_Settings_CurrentBuildTargetGroup";
19-
private const string HasCheckedXRSupportKey = "_MixedRealityToolkit_Editor_Settings_HasCheckedXRSupport";
2019

2120
private static BuildTargetGroup currentBuildTargetGroup = BuildTargetGroup.Unknown;
2221

2322
private static string mixedRealityToolkit_RelativeFolderPath = string.Empty;
2423

25-
private static bool hasCheckedVREnabled = false;
26-
2724
public static string MixedRealityToolkit_RelativeFolderPath
2825
{
2926
get
@@ -42,7 +39,6 @@ public static string MixedRealityToolkit_RelativeFolderPath
4239

4340
static EnforceEditorSettings()
4441
{
45-
4642
SetIconTheme();
4743

4844
if (!IsNewSession)
@@ -53,90 +49,34 @@ static EnforceEditorSettings()
5349
bool refresh = false;
5450
bool restart = false;
5551

56-
if (EditorSettings.serializationMode != SerializationMode.ForceText)
52+
if (EditorSettings.serializationMode != SerializationMode.ForceText ||
53+
PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) != ScriptingImplementation.IL2CPP ||
54+
!EditorSettings.externalVersionControl.Equals("Visible Meta Files") ||
55+
!PlayerSettings.virtualRealitySupported)
5756
{
5857
if (EditorUtility.DisplayDialog(
59-
"Force Text Asset Serialization?",
60-
"The Mixed Reality Toolkit is easier to maintain if the asset serialization mode for this project is set to \"Force Text\". Would you like to make this change?",
61-
"Force Text Serialization",
58+
"Apply Mixed Reality Toolkit Default Settings?",
59+
"The Mixed Reality Toolkit needs to apply the following settings to your project:\n\n" +
60+
"- Enable XR Settings for your current platform\n" +
61+
"- Force Text Serialization\n" +
62+
"- Visible meta files\n" +
63+
"- Change the Scripting Backend to use IL2CPP\n\n" +
64+
"Would you like to make this change?",
65+
"Update Settings",
6266
"Later"))
6367
{
6468
EditorSettings.serializationMode = SerializationMode.ForceText;
65-
Debug.Log("Setting Force Text Serialization");
66-
refresh = true;
67-
}
68-
}
69-
70-
if (!EditorSettings.externalVersionControl.Equals("Visible Meta Files"))
71-
{
72-
if (EditorUtility.DisplayDialog(
73-
"Make Meta Files Visible?",
74-
"The Mixed Reality Toolkit would like to make meta files visible so they can be more easily handled with common version control systems. Would you like to make this change?",
75-
"Enable Visible Meta Files",
76-
"Later"))
77-
{
7869
EditorSettings.externalVersionControl = "Visible Meta Files";
79-
Debug.Log($"Updated external version control mode: {EditorSettings.externalVersionControl}");
80-
refresh = true;
81-
}
82-
}
83-
84-
refresh |= CheckVRSettings();
85-
86-
var currentScriptingBackend = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup);
87-
88-
if (currentScriptingBackend != ScriptingImplementation.IL2CPP)
89-
{
90-
if (EditorUtility.DisplayDialog(
91-
"Change the Scripting Backend to IL2CPP?",
92-
"The Mixed Reality Toolkit would like to change the Scripting Backend to use IL2CPP.\n\n" +
93-
"Would you like to make this change?",
94-
"Enable IL2CPP",
95-
"Later"))
96-
{
9770
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup, ScriptingImplementation.IL2CPP);
98-
Debug.Log("Updated Scripting Backend to use IL2CPP");
71+
PlayerSettings.virtualRealitySupported = true;
9972
refresh = true;
10073
}
10174
}
10275

10376
if (PlayerSettings.scriptingRuntimeVersion != ScriptingRuntimeVersion.Latest)
10477
{
105-
if (EditorUtility.DisplayDialog(
106-
"Change the Scripting Runtime Version to the 4.x Equivalent?",
107-
"The Mixed Reality Toolkit would like to change the Scripting Runtime Version to use the .NET 4.x Equivalent.\n\n" +
108-
"In order for the change to take place the Editor must be restarted, and any changes will be saved.\n\n" +
109-
"WARNING: If you do not make this change, then your project will fail to compile.\n\n" +
110-
"Would you like to make this change?",
111-
"Enable .NET 4.x Equivalent",
112-
"Later"))
113-
{
114-
PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest;
115-
restart = true;
116-
}
117-
else
118-
{
119-
Debug.LogWarning("You must change the Runtime Scripting Version to 4.x in the Player Settings to get this asset to compile correctly.");
120-
}
121-
}
122-
123-
if (PlayerSettings.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest)
124-
{
125-
var currentApiCompatibility = PlayerSettings.GetApiCompatibilityLevel(EditorUserBuildSettings.selectedBuildTargetGroup);
126-
if (currentApiCompatibility != ApiCompatibilityLevel.NET_4_6 && currentApiCompatibility != ApiCompatibilityLevel.NET_Standard_2_0)
127-
{
128-
if (EditorUtility.DisplayDialog(
129-
"Change the Scripting API Compatibility to .NET 4.x?",
130-
"The Mixed Reality Toolkit would like to change the Scripting API Compatibility to use .NET 4.x\n\n" +
131-
"Would you like to make this change?",
132-
"Enable .NET 4.x",
133-
"Later"))
134-
{
135-
PlayerSettings.SetApiCompatibilityLevel(EditorUserBuildSettings.selectedBuildTargetGroup, ApiCompatibilityLevel.NET_4_6);
136-
Debug.Log("Updated Scripting API Compatibility to .NET 4.x");
137-
refresh = true;
138-
}
139-
}
78+
PlayerSettings.scriptingRuntimeVersion = ScriptingRuntimeVersion.Latest;
79+
restart = true;
14080
}
14181

14282
if (refresh || restart)
@@ -151,40 +91,6 @@ static EnforceEditorSettings()
15191
}
15292
}
15393

154-
private static bool CheckVRSettings()
155-
{
156-
var currentBuildTarget = EditorUserBuildSettings.activeBuildTarget;
157-
var availableVRDevices = VREditor.GetAvailableVirtualRealitySDKs(currentBuildTargetGroup);
158-
var enabledVRDevices = VREditor.GetVREnabledDevicesOnTarget(currentBuildTarget);
159-
160-
bool isVRDeviceEnabled = false;
161-
162-
Debug.Log("Available Devices:");
163-
foreach (string availableVRDevice in availableVRDevices)
164-
{
165-
isVRDeviceEnabled |= VREditor.IsVRDeviceEnabledForBuildTarget(currentBuildTarget, availableVRDevice);
166-
Debug.Log(availableVRDevice);
167-
}
168-
169-
Debug.Log("Enabled Devices:");
170-
foreach (var enabledVRDevice in enabledVRDevices)
171-
{
172-
Debug.Log(enabledVRDevice);
173-
}
174-
175-
if (!isVRDeviceEnabled || !PlayerSettings.virtualRealitySupported)
176-
{
177-
if (EditorUtility.DisplayDialog("Activate XR Settings?",
178-
"The Mixed Reality Toolkit would like to enable the XR Settings for you.", "Ok", "Later"))
179-
{
180-
181-
}
182-
}
183-
184-
//VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.WSA, new[] { "WindowsMR" });
185-
return false;
186-
}
187-
18894
/// <summary>
18995
/// Returns true the first time it is called within this editor session, and false for all subsequent calls.
19096
/// <remarks>A new session is also true if the editor build target group is changed.</remarks>
@@ -193,10 +99,15 @@ private static bool IsNewSession
19399
{
194100
get
195101
{
102+
if (!SessionState.GetBool(SessionKey, false))
103+
{
104+
SessionState.SetBool(SessionKey, true);
105+
return true;
106+
}
107+
196108
if (currentBuildTargetGroup == BuildTargetGroup.Unknown)
197109
{
198110
currentBuildTargetGroup = (BuildTargetGroup)SessionState.GetInt(BuildTargetGroupKey, (int)EditorUserBuildSettings.selectedBuildTargetGroup);
199-
SessionState.SetBool(HasCheckedXRSupportKey, false);
200111
}
201112

202113
if (currentBuildTargetGroup != EditorUserBuildSettings.selectedBuildTargetGroup)
@@ -206,18 +117,6 @@ private static bool IsNewSession
206117
return true;
207118
}
208119

209-
if (!SessionState.GetBool(HasCheckedXRSupportKey, false))
210-
{
211-
SessionState.SetBool(HasCheckedXRSupportKey, true);
212-
return true;
213-
}
214-
215-
if (!SessionState.GetBool(SessionKey, false))
216-
{
217-
SessionState.SetBool(SessionKey, true);
218-
return true;
219-
}
220-
221120
return false;
222121
}
223122
}

0 commit comments

Comments
 (0)