Skip to content

Commit 2d376f3

Browse files
better capability handling.
1 parent 27b3f6d commit 2d376f3

File tree

4 files changed

+149
-21
lines changed

4 files changed

+149
-21
lines changed

Assets/HoloToolkit/Utilities/Scripts/Editor/AutoConfigureWindow.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ public abstract class AutoConfigureWindow<TSetting> : EditorWindow
2626
#region Internal Methods
2727
private void SettingToggle(TSetting setting)
2828
{
29+
EditorGUI.BeginChangeCheck();
2930
// Draw and update setting flag
3031
values[setting] = GUILayout.Toggle(values[setting], new GUIContent(names[setting]));
3132

33+
if (EditorGUI.EndChangeCheck())
34+
{
35+
OnGuiChanged();
36+
}
37+
3238
// If this control is the one under the mouse, update the status message
3339
if ((Event.current.type == EventType.Repaint) && (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)))
3440
{
@@ -53,6 +59,12 @@ private void SettingToggle(TSetting setting)
5359
/// Called when string names and descriptions should be loaded.
5460
/// </summary>
5561
protected abstract void LoadStrings();
62+
63+
/// <summary>
64+
/// Called when a toggle has been flipped and a change has been detected.
65+
/// </summary>
66+
protected abstract void OnGuiChanged();
67+
5668
#endregion // Overridables / Event Triggers
5769

5870
#region Overrides / Event Handlers

Assets/HoloToolkit/Utilities/Scripts/Editor/CapabilitySettingsWindow.cs

Lines changed: 90 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using System;
45
using UnityEditor;
56
using UnityEngine;
67

@@ -15,21 +16,71 @@ public class CapabilitySettingsWindow : AutoConfigureWindow<PlayerSettings.WSACa
1516

1617
private void ApplySetting(PlayerSettings.WSACapability setting)
1718
{
19+
switch (setting)
20+
{
21+
case PlayerSettings.WSACapability.InternetClient:
22+
if (Values[setting])
23+
{
24+
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.InternetClientServer, false);
25+
}
26+
break;
27+
case PlayerSettings.WSACapability.InternetClientServer:
28+
if (Values[setting])
29+
{
30+
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.InternetClient, false);
31+
}
32+
break;
33+
case PlayerSettings.WSACapability.PrivateNetworkClientServer:
34+
if (Values[setting])
35+
{
36+
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.InternetClient, false);
37+
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.InternetClientServer, true);
38+
}
39+
break;
40+
case PlayerSettings.WSACapability.Chat:
41+
case PlayerSettings.WSACapability.WebCam:
42+
case PlayerSettings.WSACapability.AllJoyn:
43+
case PlayerSettings.WSACapability.Location:
44+
case PlayerSettings.WSACapability.VoipCall:
45+
case PlayerSettings.WSACapability.Objects3D:
46+
case PlayerSettings.WSACapability.PhoneCall:
47+
case PlayerSettings.WSACapability.Bluetooth:
48+
case PlayerSettings.WSACapability.Proximity:
49+
case PlayerSettings.WSACapability.Microphone:
50+
case PlayerSettings.WSACapability.MusicLibrary:
51+
case PlayerSettings.WSACapability.VideosLibrary:
52+
case PlayerSettings.WSACapability.CodeGeneration:
53+
case PlayerSettings.WSACapability.PicturesLibrary:
54+
case PlayerSettings.WSACapability.RemovableStorage:
55+
case PlayerSettings.WSACapability.SpatialPerception:
56+
case PlayerSettings.WSACapability.BlockedChatMessages:
57+
case PlayerSettings.WSACapability.HumanInterfaceDevice:
58+
case PlayerSettings.WSACapability.SharedUserCertificates:
59+
case PlayerSettings.WSACapability.UserAccountInformation:
60+
case PlayerSettings.WSACapability.InputInjectionBrokered:
61+
case PlayerSettings.WSACapability.EnterpriseAuthentication:
62+
break;
63+
default:
64+
throw new ArgumentOutOfRangeException("setting", setting, null);
65+
}
66+
1867
PlayerSettings.WSA.SetCapability(setting, Values[setting]);
1968
}
2069

2170
private void LoadSetting(PlayerSettings.WSACapability setting)
2271
{
2372
Values[setting] = PlayerSettings.WSA.GetCapability(setting);
2473
}
74+
2575
#endregion // Internal Methods
2676

2777
#region Overrides / Event Handlers
78+
2879
protected override void ApplySettings()
2980
{
3081
ApplySetting(PlayerSettings.WSACapability.Microphone);
31-
ApplySetting(PlayerSettings.WSACapability.SpatialPerception);
3282
ApplySetting(PlayerSettings.WSACapability.WebCam);
83+
ApplySetting(PlayerSettings.WSACapability.SpatialPerception);
3384
ApplySetting(PlayerSettings.WSACapability.InternetClient);
3485
ApplySetting(PlayerSettings.WSACapability.InternetClientServer);
3586
ApplySetting(PlayerSettings.WSACapability.PrivateNetworkClientServer);
@@ -38,32 +89,60 @@ protected override void ApplySettings()
3889
protected override void LoadSettings()
3990
{
4091
LoadSetting(PlayerSettings.WSACapability.Microphone);
41-
LoadSetting(PlayerSettings.WSACapability.SpatialPerception);
4292
LoadSetting(PlayerSettings.WSACapability.WebCam);
93+
LoadSetting(PlayerSettings.WSACapability.SpatialPerception);
4394
LoadSetting(PlayerSettings.WSACapability.InternetClient);
4495
LoadSetting(PlayerSettings.WSACapability.InternetClientServer);
4596
LoadSetting(PlayerSettings.WSACapability.PrivateNetworkClientServer);
4697
}
4798

99+
protected override void OnGuiChanged()
100+
{
101+
ApplySettings();
102+
LoadSettings();
103+
}
104+
48105
protected override void LoadStrings()
49106
{
50107
Names[PlayerSettings.WSACapability.Microphone] = "Microphone";
51-
Descriptions[PlayerSettings.WSACapability.Microphone] = "Required for access to the HoloLens microphone. This includes behaviors like DictationRecognizer, GrammarRecognizer, and KeywordRecognizer. This capability is NOT required for the 'Select' keyword.\n\nRecommendation: Only enable if your application needs access to the microphone beyond the 'Select' keyword.The microphone is considered a privacy sensitive resource.";
52-
53-
Names[PlayerSettings.WSACapability.SpatialPerception] = "Spatial Perception";
54-
Descriptions[PlayerSettings.WSACapability.SpatialPerception] = "Required for access to the HoloLens world mapping capabilities.These include behaviors like SurfaceObserver, SpatialMappingManager and SpatialAnchor.\n\nRecommendation: Enabled, unless your application doesn't use spatial mapping or spatial collisions in any way.";
108+
Descriptions[PlayerSettings.WSACapability.Microphone] = "Required for access to the Microphone. This includes behaviors like DictationRecognizer, " +
109+
"GrammarRecognizer, and KeywordRecognizer. This capability is NOT required for the 'Select' keyword.\n\n" +
110+
"Recommendation: Only enable if your application needs access to the microphone beyond the 'Select' keyword. " +
111+
"The microphone is considered a privacy sensitive resource.";
55112

56113
Names[PlayerSettings.WSACapability.WebCam] = "Webcam";
57-
Descriptions[PlayerSettings.WSACapability.WebCam] = "Required for access to the HoloLens RGB camera (also known as the locatable camera). This includes APIs like PhotoCapture and VideoCapture. This capability is NOT required for mixed reality streaming or for capturing photos or videos using the start menu.\n\nRecommendation: Only enable if your application needs to programmatically capture photos or videos from the RGB camera.The RGB camera is considered a privacy sensitive resource.";
114+
Descriptions[PlayerSettings.WSACapability.WebCam] = "Required for access to the RGB camera (also known as the locatable camera). This includes " +
115+
"APIs like PhotoCapture and VideoCapture. This capability is NOT required for mixed reality streaming " +
116+
"or for capturing photos or videos using the start menu.\n\n" +
117+
"Recommendation: Only enable if your application needs to programmatically capture photos or videos " +
118+
"from the RGB camera. The RGB camera is considered a privacy sensitive resource.\n\nNote: The webcam capability " +
119+
"only grants access to the video stream. In order to grant access to the audio stream as well, the microphone " +
120+
"capability must be added.";
121+
122+
Names[PlayerSettings.WSACapability.SpatialPerception] = "Spatial Perception";
123+
Descriptions[PlayerSettings.WSACapability.SpatialPerception] = "Required for access to the HoloLens world mapping capabilities. These include behaviors like " +
124+
"SurfaceObserver, SpatialMappingManager and SpatialAnchor.\n\n" +
125+
"Recommendation: Enabled, unless your application doesn't use spatial mapping or spatial " +
126+
"collisions in any way.";
58127

59128
Names[PlayerSettings.WSACapability.InternetClient] = "Internet Client";
60-
Descriptions[PlayerSettings.WSACapability.InternetClient] = "Required if your application needs to access the Internet.\n\nRecommendation: Leave unchecked unless your application uses online services.";
129+
Descriptions[PlayerSettings.WSACapability.InternetClient] = "The Internet Client capability indicates that apps can receive incoming data from the Internet. " +
130+
"Cannot act as a server. No local network access.\n\n" +
131+
"Recommendation: Leave unchecked unless your application uses online services.";
61132

62133
Names[PlayerSettings.WSACapability.InternetClientServer] = "Internet Client Server";
63-
Descriptions[PlayerSettings.WSACapability.InternetClientServer] = "Required if your application uses the Sharing Services.";
134+
Descriptions[PlayerSettings.WSACapability.InternetClientServer] = "The Internet Client Server capability indicates that apps can receive incoming data from the " +
135+
"Internet. Can act as a server. No local network access.\n\nNote: Apps that enable peer-to-peer " +
136+
"(P2P) scenarios where the app needs to listen for incoming network connections should use " +
137+
"Internet Client Server. The Internet Client Server capability includes the access that the " +
138+
"Internet Client capability provides, so you don't need to specify Internet Client when you specify " +
139+
"Internet Client Server.";
64140

65141
Names[PlayerSettings.WSACapability.PrivateNetworkClientServer] = "Private Network Client Server";
66-
Descriptions[PlayerSettings.WSACapability.PrivateNetworkClientServer] = "Required if your application uses the Sharing Services.";
142+
Descriptions[PlayerSettings.WSACapability.PrivateNetworkClientServer] = "The Private Network Client Server capability provides inbound and outbound access to home and " +
143+
"work networks through the firewall. This capability is typically used for games that " +
144+
"communicate across the local area network (LAN), and for apps that share data across a variety " +
145+
"of local devices.\n\nNote: On Windows, this capability does not provide access to the Internet.";
67146
}
68147

69148
protected override void OnEnable()
@@ -75,6 +154,7 @@ protected override void OnEnable()
75154
minSize = new Vector2(350, 350);
76155
maxSize = minSize;
77156
}
157+
78158
#endregion // Overrides / Event Handlers
79159
}
80160
}

0 commit comments

Comments
 (0)