Skip to content

Commit fdf103e

Browse files
author
David Kline
authored
Merge pull request #2983 from StephenHodgson/vNEXT-SdkActivationPrompt
Consolidated setup prompts into one, and added VR setup
2 parents 7b17520 + 7eca8c5 commit fdf103e

File tree

2 files changed

+44
-88
lines changed

2 files changed

+44
-88
lines changed

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

Lines changed: 29 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@
44
using System.IO;
55
using UnityEngine;
66
using UnityEditor;
7+
using UnityEditor.Build;
78

89
namespace Microsoft.MixedReality.Toolkit.Core.Utilities.Editor.Setup
910
{
1011
/// <summary>
1112
/// Sets Force Text Serialization and visible meta files in all projects that use the Mixed Reality Toolkit.
1213
/// </summary>
1314
[InitializeOnLoad]
14-
public class MixedRealityEditorSettings
15+
public class MixedRealityEditorSettings : IActiveBuildTargetChanged
1516
{
1617
private const string SessionKey = "_MixedRealityToolkit_Editor_ShownSettingsPrompts";
17-
private const string BuildTargetKey = "_MixedRealityToolkit_Editor_Settings_CurrentBuildTarget";
18-
19-
private static BuildTargetGroup currentBuildTargetGroup = BuildTargetGroup.Unknown;
2018

2119
private static string mixedRealityToolkit_RelativeFolderPath = string.Empty;
2220

@@ -42,96 +40,42 @@ static MixedRealityEditorSettings()
4240
{
4341
SetIconTheme();
4442

45-
if (!IsNewSession())
43+
if (!IsNewSession)
4644
{
4745
return;
4846
}
4947

5048
bool refresh = false;
5149
bool restart = false;
5250

53-
if (EditorSettings.serializationMode != SerializationMode.ForceText)
51+
if (EditorSettings.serializationMode != SerializationMode.ForceText ||
52+
PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) != ScriptingImplementation.IL2CPP ||
53+
!EditorSettings.externalVersionControl.Equals("Visible Meta Files") ||
54+
!PlayerSettings.virtualRealitySupported)
5455
{
5556
if (EditorUtility.DisplayDialog(
56-
"Force Text Asset Serialization?",
57-
"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?",
58-
"Force Text Serialization",
57+
"Apply Mixed Reality Toolkit Default Settings?",
58+
"The Mixed Reality Toolkit needs to apply the following settings to your project:\n\n" +
59+
"- Enable XR Settings for your current platform\n" +
60+
"- Force Text Serialization\n" +
61+
"- Visible meta files\n" +
62+
"- Change the Scripting Backend to use IL2CPP\n\n" +
63+
"Would you like to make this change?",
64+
"Apply",
5965
"Later"))
6066
{
6167
EditorSettings.serializationMode = SerializationMode.ForceText;
62-
Debug.Log("Setting Force Text Serialization");
63-
refresh = true;
64-
}
65-
}
66-
67-
if (!EditorSettings.externalVersionControl.Equals("Visible Meta Files"))
68-
{
69-
if (EditorUtility.DisplayDialog(
70-
"Make Meta Files Visible?",
71-
"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?",
72-
"Enable Visible Meta Files",
73-
"Later"))
74-
{
7568
EditorSettings.externalVersionControl = "Visible Meta Files";
76-
Debug.Log("Updated external version control mode: " + EditorSettings.externalVersionControl);
77-
refresh = true;
78-
}
79-
}
80-
81-
var currentScriptingBackend = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup);
82-
83-
if (currentScriptingBackend != ScriptingImplementation.IL2CPP)
84-
{
85-
if (EditorUtility.DisplayDialog(
86-
"Change the Scripting Backend to IL2CPP?",
87-
"The Mixed Reality Toolkit would like to change the Scripting Backend to use IL2CPP.\n\n" +
88-
"Would you like to make this change?",
89-
"Enable IL2CPP",
90-
"Later"))
91-
{
9269
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup, ScriptingImplementation.IL2CPP);
93-
Debug.Log("Updated Scripting Backend to use IL2CPP");
70+
PlayerSettings.virtualRealitySupported = true;
9471
refresh = true;
9572
}
9673
}
9774

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

13781
if (refresh || restart)
@@ -148,24 +92,17 @@ static MixedRealityEditorSettings()
14892

14993
/// <summary>
15094
/// Returns true the first time it is called within this editor session, and false for all subsequent calls.
151-
/// <remarks>A new session is also true if the editor build target is changed.</remarks>
95+
/// <remarks>A new session is also true if the editor build target group is changed.</remarks>
15296
/// </summary>
153-
private static bool IsNewSession()
97+
private static bool IsNewSession
15498
{
155-
if (currentBuildTargetGroup == BuildTargetGroup.Unknown)
99+
get
156100
{
157-
currentBuildTargetGroup = (BuildTargetGroup)SessionState.GetInt(BuildTargetKey, (int)EditorUserBuildSettings.selectedBuildTargetGroup);
158-
}
101+
if (SessionState.GetBool(SessionKey, false)) { return false; }
159102

160-
if (!SessionState.GetBool(SessionKey, false) || currentBuildTargetGroup != EditorUserBuildSettings.selectedBuildTargetGroup)
161-
{
162-
currentBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
163-
SessionState.SetInt(BuildTargetKey, (int)EditorUserBuildSettings.selectedBuildTargetGroup);
164103
SessionState.SetBool(SessionKey, true);
165104
return true;
166105
}
167-
168-
return false;
169106
}
170107

171108
private static bool FindDirectory(string directoryPathToSearch, string directoryName, out string path)
@@ -227,5 +164,12 @@ private static void SetIconTheme()
227164
AssetDatabase.SaveAssets();
228165
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
229166
}
167+
168+
public int callbackOrder { get; } = 0;
169+
170+
public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget)
171+
{
172+
SessionState.SetBool(SessionKey, false);
173+
}
230174
}
231175
}

ProjectSettings/ProjectSettings.asset

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,8 @@ PlayerSettings:
275275
m_BuildTargetGraphicsAPIs: []
276276
m_BuildTargetVRSettings:
277277
- m_BuildTarget: Android
278-
m_Enabled: 0
279-
m_Devices:
280-
- Oculus
278+
m_Enabled: 1
279+
m_Devices: []
281280
- m_BuildTarget: Metro
282281
m_Enabled: 1
283282
m_Devices:
@@ -304,6 +303,7 @@ PlayerSettings:
304303
- m_BuildTarget: Standalone
305304
m_Enabled: 1
306305
m_Devices:
306+
- Oculus
307307
- OpenVR
308308
- m_BuildTarget: Tizen
309309
m_Enabled: 0
@@ -652,27 +652,39 @@ PlayerSettings:
652652
platformCapabilities:
653653
WindowsStoreApps:
654654
AllJoyn: False
655+
Appointments: False
656+
BackgroundMediaPlayback: False
655657
BlockedChatMessages: False
656658
Bluetooth: False
657659
Chat: False
658660
CodeGeneration: False
661+
Contacts: False
659662
EnterpriseAuthentication: False
660663
HumanInterfaceDevice: False
661664
InputInjectionBrokered: False
662665
InternetClient: True
663666
InternetClientServer: False
664667
Location: False
668+
LowLevelDevices: False
665669
Microphone: True
666670
MusicLibrary: False
667671
Objects3D: False
672+
OfflineMapsManagement: False
668673
PhoneCall: False
674+
PhoneCallHistoryPublic: False
669675
PicturesLibrary: False
676+
PointOfService: False
670677
PrivateNetworkClientServer: False
671678
Proximity: False
679+
RecordedCallsFolder: False
680+
RemoteSystem: False
672681
RemovableStorage: False
673682
SharedUserCertificates: False
674683
SpatialPerception: True
684+
SystemManagement: False
675685
UserAccountInformation: False
686+
UserDataTasks: False
687+
UserNotificationListener: False
676688
VideosLibrary: False
677689
VoipCall: False
678690
WebCam: False

0 commit comments

Comments
 (0)