forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectSettingsWindow.cs
More file actions
169 lines (145 loc) · 7.81 KB
/
Copy pathProjectSettingsWindow.cs
File metadata and controls
169 lines (145 loc) · 7.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System;
using UnityEditor;
using UnityEngine;
namespace HoloToolkit.Unity
{
/// <summary>
/// Renders the UI and handles update logic for HoloToolkit/Configure/Apply HoloLens Project Settings.
/// </summary>
public class ProjectSettingsWindow : AutoConfigureWindow<ProjectSettingsWindow.ProjectSetting>
{
#region Nested Types
public enum ProjectSetting
{
BuildWsaUwp,
WsaEnableVR,
WsaUwpBuildToD3D,
WsaFastestQuality,
SharingServices
}
#endregion // Nested Types
#region Overrides / Event Handlers
protected override void ApplySettings()
{
// Apply individual settings
if (Values[ProjectSetting.BuildWsaUwp])
{
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.WSAPlayer)
{
EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
}
else
{
UpdateSettings(EditorUserBuildSettings.activeBuildTarget);
}
}
else
{
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
}
}
protected override void LoadSettings()
{
for (int i = (int)ProjectSetting.BuildWsaUwp; i <= (int)ProjectSetting.SharingServices; i++)
{
switch ((ProjectSetting)i)
{
case ProjectSetting.BuildWsaUwp:
case ProjectSetting.WsaEnableVR:
case ProjectSetting.WsaUwpBuildToD3D:
case ProjectSetting.WsaFastestQuality:
Values[(ProjectSetting)i] = true;
break;
case ProjectSetting.SharingServices:
Values[(ProjectSetting)i] = EditorPrefsUtility.GetEditorPref(Names[(ProjectSetting)i], false);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
private void UpdateSettings(BuildTarget currentBuildTarget)
{
if (currentBuildTarget != BuildTarget.WSAPlayer) { return; }
EditorUserBuildSettings.wsaUWPBuildType = Values[ProjectSetting.WsaUwpBuildToD3D]
? WSAUWPBuildType.D3D
: WSAUWPBuildType.XAML;
if (Values[ProjectSetting.WsaFastestQuality])
{
int settingId = -1;
for (var i = 0; i < QualitySettings.names.Length; i++)
{
if (QualitySettings.names[i].Equals("Fastest"))
{
QualitySettings.SetQualityLevel(i);
settingId = i;
break;
}
}
if (settingId < 0)
{
Debug.LogWarning("Failed to find Quality Setting 'Fastest'");
}
}
UnityEditorInternal.VR.VREditor.SetVREnabledOnTargetGroup(BuildTargetGroup.WSA, Values[ProjectSetting.WsaEnableVR]);
if (Values[ProjectSetting.WsaEnableVR])
{
EditorUserBuildSettings.wsaSubtarget = WSASubtarget.HoloLens;
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.WSA, new[] { "HoloLens" });
}
EditorPrefsUtility.SetEditorPref(Names[ProjectSetting.SharingServices], Values[ProjectSetting.SharingServices]);
if (Values[ProjectSetting.SharingServices])
{
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.InternetClientServer, true);
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.PrivateNetworkClientServer, true);
}
else
{
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.InternetClient, false);
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.InternetClientServer, false);
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.PrivateNetworkClientServer, false);
}
Close();
}
protected override void OnGuiChanged()
{
}
protected override void LoadStrings()
{
Names[ProjectSetting.BuildWsaUwp] = "Target Windows Store and UWP";
Descriptions[ProjectSetting.BuildWsaUwp] = "Required\n\nSwitches the currently active target to produce a Store app targeting the Universal Windows Platform.\n\n" +
"Since HoloLens only supports Windows Store apps, this option should remain checked unless you plan to manually switch " +
"the target later before you build.";
Names[ProjectSetting.WsaEnableVR] = "Enable VR and Target HoloLens Device";
Descriptions[ProjectSetting.WsaEnableVR] = "Required\n\nEnables VR for Windows Store apps and adds the HoloLens as a target VR device.\n\n" +
"The application will not compile for HoloLens and tools like Holographic Remoting will not function " +
"without this enabled. Therefore this option should remain checked unless you plan to manually " +
"perform these steps later.";
Names[ProjectSetting.WsaUwpBuildToD3D] = "Build for Direct3D";
Descriptions[ProjectSetting.WsaUwpBuildToD3D] = "Recommended\n\nProduces an app that targets Direct3D instead of Xaml.\n\nPure Direct3D apps run " +
"faster than applications that include Xaml. This option should remain checked unless you plan to " +
"overlay Unity content with Xaml content or you plan to switch between Unity views and Xaml views at runtime.";
Names[ProjectSetting.WsaFastestQuality] = "Set Quality to Fastest";
Descriptions[ProjectSetting.WsaFastestQuality] = "Recommended\n\nChanges the quality settings for Windows Store apps to the 'Fastest' setting.\n\n" +
"'Fastest' is the recommended quality setting for HoloLens apps, but this option can be unchecked " +
"if you have already optimized your project for the HoloLens.";
Names[ProjectSetting.SharingServices] = "Enable Sharing Services";
Descriptions[ProjectSetting.SharingServices] = "Enables the use of the Sharing Services in your project.\n\n" +
"Requires the SpatialPerception, InternetClient, InternetClientServer, PrivateNetworkClientServer, " +
"and Microphone Capabilities.\n\n" +
"Start the Sharing Server though HoloToolkit->Sharing Service->Launch Sharing Service.";
}
protected override void OnEnable()
{
// Pass to base first
base.OnEnable();
AutoConfigureMenu.ActiveBuildTargetChanged += UpdateSettings;
// Set size
minSize = new Vector2(350, 350);
maxSize = minSize;
}
#endregion // Overrides / Event Handlers
}
}