Skip to content

Commit 5582a47

Browse files
Better session handling
1 parent 4b6a302 commit 5582a47

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

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

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@
44
using System.IO;
55
using UnityEngine;
66
using UnityEditor;
7-
using UnityEditorInternal.VR;
7+
using UnityEditor.Build;
88

99
namespace Microsoft.MixedReality.Toolkit.Core.Utilities.Editor.Setup
1010
{
1111
/// <summary>
1212
/// Sets Force Text Serialization and visible meta files in all projects that use the Mixed Reality Toolkit.
1313
/// </summary>
1414
[InitializeOnLoad]
15-
public class EnforceEditorSettings
15+
public class EnforceEditorSettings : IActiveBuildTargetChanged
1616
{
1717
private const string SessionKey = "_MixedRealityToolkit_Editor_ShownSettingsPrompts";
18-
private const string BuildTargetGroupKey = "_MixedRealityToolkit_Editor_Settings_CurrentBuildTargetGroup";
19-
20-
private static BuildTargetGroup currentBuildTargetGroup = BuildTargetGroup.Unknown;
2118

2219
private static string mixedRealityToolkit_RelativeFolderPath = string.Empty;
2320

@@ -62,7 +59,7 @@ static EnforceEditorSettings()
6259
"- Visible meta files\n" +
6360
"- Change the Scripting Backend to use IL2CPP\n\n" +
6461
"Would you like to make this change?",
65-
"Update Settings",
62+
"Apply",
6663
"Later"))
6764
{
6865
EditorSettings.serializationMode = SerializationMode.ForceText;
@@ -99,25 +96,10 @@ private static bool IsNewSession
9996
{
10097
get
10198
{
102-
if (!SessionState.GetBool(SessionKey, false))
103-
{
104-
SessionState.SetBool(SessionKey, true);
105-
return true;
106-
}
99+
if (SessionState.GetBool(SessionKey, false)) { return false; }
107100

108-
if (currentBuildTargetGroup == BuildTargetGroup.Unknown)
109-
{
110-
currentBuildTargetGroup = (BuildTargetGroup)SessionState.GetInt(BuildTargetGroupKey, (int)EditorUserBuildSettings.selectedBuildTargetGroup);
111-
}
112-
113-
if (currentBuildTargetGroup != EditorUserBuildSettings.selectedBuildTargetGroup)
114-
{
115-
currentBuildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
116-
SessionState.SetInt(BuildTargetGroupKey, (int)EditorUserBuildSettings.selectedBuildTargetGroup);
117-
return true;
118-
}
119-
120-
return false;
101+
SessionState.SetBool(SessionKey, true);
102+
return true;
121103
}
122104
}
123105

@@ -180,5 +162,12 @@ private static void SetIconTheme()
180162
AssetDatabase.SaveAssets();
181163
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
182164
}
165+
166+
public int callbackOrder { get; } = 0;
167+
168+
public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget)
169+
{
170+
SessionState.SetBool(SessionKey, false);
171+
}
183172
}
184173
}

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)