Skip to content

Commit 8427ef0

Browse files
committed
Add a new configurator to facilitate setup
1 parent 265a0ea commit 8427ef0

8 files changed

+641
-106
lines changed

Assets/MRTK/Core/Inspectors/MRTK.Inspectors.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"Microsoft.MixedReality.Toolkit.Editor.BuildAndDeploy",
77
"Microsoft.MixedReality.Toolkit.Editor.ClassExtensions",
88
"Microsoft.MixedReality.Toolkit.Editor.Utilities",
9-
"Unity.TextMeshPro.Editor"
9+
"Unity.TextMeshPro.Editor",
10+
"Unity.TextMeshPro"
1011
],
1112
"optionalUnityReferences": [],
1213
"includePlatforms": [

Assets/MRTK/Core/Inspectors/Setup/MixedRealityEditorSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private static void ShowProjectConfigurationDialog()
8989
&& !MixedRealityProjectPreferences.IgnoreSettingsPrompt
9090
&& !MixedRealityProjectConfigurator.IsProjectConfigured())
9191
{
92-
MixedRealityProjectConfiguratorWindow.ShowWindow();
92+
//MixedRealityProjectConfiguratorWindow.ShowWindow();
9393
}
9494
}
9595

Assets/MRTK/Core/Inspectors/Setup/MixedRealityProjectConfiguratorWindow.cs

Lines changed: 16 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Microsoft.MixedReality.Toolkit.Utilities.Editor
1212
{
13-
public class MixedRealityProjectConfiguratorWindow : EditorWindow
13+
public class MixedRealityProjectConfiguratorWindow
1414
{
1515
private readonly Dictionary<MRConfig, bool> trackToggles = new Dictionary<MRConfig, bool>()
1616
{
@@ -56,25 +56,22 @@ public class MixedRealityProjectConfiguratorWindow : EditorWindow
5656
private readonly GUIContent LaterButtonContent = new GUIContent("Later", "Do not show this pop-up notification until next session");
5757
private readonly GUIContent IgnoreButtonContent = new GUIContent("Ignore", "Modify this preference under Edit > Project Settings > Mixed Reality Toolkit");
5858

59-
private bool showConfigurations = true;
59+
//private bool showConfigurations = true;
6060

6161
/// <summary>
6262
/// Show the MRTK Project Configurator utility window or focus if already opened
6363
/// </summary>
64-
[MenuItem("Mixed Reality Toolkit/Utilities/Configure Unity Project", false, 499)]
65-
public static void ShowWindow()
64+
public static MixedRealityProjectConfiguratorWindow GetObj()
6665
{
6766
// There should be only one configurator window open as a "pop-up". If already open, then just force focus on our instance
6867
if (IsOpen)
6968
{
70-
Instance.Focus();
69+
return Instance;
7170
}
7271
else
7372
{
74-
var window = CreateInstance<MixedRealityProjectConfiguratorWindow>();
75-
window.titleContent = new GUIContent("MRTK Project Configurator", EditorGUIUtility.IconContent("_Popup").image);
76-
window.position = new Rect(Screen.width / 2.0f, Screen.height / 2.0f, Default_Window_Height, Default_Window_Width);
77-
window.ShowUtility();
73+
Instance = new MixedRealityProjectConfiguratorWindow();
74+
return Instance;
7875
}
7976
}
8077

@@ -95,77 +92,14 @@ private void CompilationPipeline_assemblyCompilationStarted(string obj)
9592
// There should be only one pop-up window which is generally tracked by IsOpen
9693
// However, when recompiling, Unity will call OnDestroy for this window but not actually destroy the editor window
9794
// This ensure we have a clean close on recompiles when this EditorWindow was open beforehand
98-
Close();
95+
//Close();
9996
}
100-
101-
private void OnGUI()
102-
{
103-
MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo();
104-
105-
string foldoutHeader;
106-
107-
if (!MixedRealityProjectConfigurator.IsProjectConfigured())
108-
{
109-
foldoutHeader = "Modify Configurations";
110-
RenderChoiceDialog();
111-
}
112-
else
113-
{
114-
foldoutHeader = "Configurations";
115-
RenderConfiguredConfirmation();
116-
}
117-
118-
EditorGUILayout.Space();
119-
120-
showConfigurations = EditorGUILayout.Foldout(showConfigurations, foldoutHeader, true);
121-
if (showConfigurations)
122-
{
123-
RenderConfigurations();
124-
}
125-
}
126-
127-
private void RenderConfiguredConfirmation()
128-
{
129-
const string dialogTitle = "Project Configuration Complete";
130-
const string dialogContent = "This Unity project is properly configured for the Mixed Reality Toolkit.";
131-
EditorGUILayout.LabelField(dialogTitle, EditorStyles.boldLabel);
132-
EditorGUILayout.LabelField(dialogContent);
133-
}
134-
135-
private void RenderChoiceDialog()
136-
{
137-
const string dialogTitle = "Apply Default Settings?";
138-
const string dialogContent = "The Mixed Reality Toolkit would like to auto-apply useful settings to this Unity project";
139-
EditorGUILayout.LabelField(dialogTitle, EditorStyles.boldLabel);
140-
EditorGUILayout.LabelField(dialogContent);
141-
142-
using (new EditorGUILayout.HorizontalScope())
143-
{
144-
if (GUILayout.Button(ApplyButtonContent))
145-
{
146-
ApplyConfigurations();
147-
Close();
148-
}
149-
150-
if (GUILayout.Button(LaterButtonContent))
151-
{
152-
MixedRealityEditorSettings.IgnoreProjectConfigForSession = true;
153-
Close();
154-
}
155-
156-
if (GUILayout.Button(IgnoreButtonContent))
157-
{
158-
MixedRealityProjectPreferences.IgnoreSettingsPrompt = true;
159-
Close();
160-
}
161-
}
162-
}
163-
97+
16498
private Vector2 scrollPosition = Vector2.zero;
16599

166-
private void RenderConfigurations()
100+
public void RenderConfigurations()
167101
{
168-
EditorGUILayout.LabelField("Enabled options will be applied to the project. Disabled items are already properly configured.");
102+
EditorGUILayout.LabelField("Enabled options below will be applied to the project. Disabled items are already properly configured.");
169103
EditorGUILayout.Space();
170104

171105
using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPosition))
@@ -174,14 +108,17 @@ private void RenderConfigurations()
174108
EditorGUILayout.LabelField("Project Settings", EditorStyles.boldLabel);
175109
RenderToggle(MRConfig.ForceTextSerialization, "Force text asset serialization");
176110
RenderToggle(MRConfig.VisibleMetaFiles, "Enable visible meta files");
177-
if (!MixedRealityOptimizeUtils.IsBuildTargetAndroid() && !MixedRealityOptimizeUtils.IsBuildTargetIOS() && XRSettingsUtilities.IsLegacyXRActive)
111+
if (!MixedRealityOptimizeUtils.IsBuildTargetAndroid() && !MixedRealityOptimizeUtils.IsBuildTargetIOS() && XRSettingsUtilities.XREnabled)
178112
{
179113
#if !UNITY_2019_3_OR_NEWER
180114
RenderToggle(MRConfig.VirtualRealitySupported, "Enable VR supported");
181115
#endif // !UNITY_2019_3_OR_NEWER
182116
}
183117
#if UNITY_2019_3_OR_NEWER
184-
RenderToggle(MRConfig.OptimalRenderingPath, "Set Single Pass Instanced rendering path (legacy XR API)");
118+
if (XRSettingsUtilities.LegacyXREnabled)
119+
{
120+
RenderToggle(MRConfig.OptimalRenderingPath, "Set Single Pass Instanced rendering path (legacy XR API)");
121+
}
185122
#else
186123
#if UNITY_ANDROID
187124
RenderToggle(MRConfig.OptimalRenderingPath, "Set Single Pass Stereo rendering path");
@@ -237,7 +174,7 @@ private void RenderConfigurations()
237174
}
238175
}
239176

240-
private void ApplyConfigurations()
177+
public void ApplyConfigurations()
241178
{
242179
var configurationFilter = new HashSet<MRConfig>();
243180
foreach (var item in trackToggles)

0 commit comments

Comments
 (0)