Skip to content

Commit 763198a

Browse files
author
lawwong
committed
Add Wave hand tracking & render model support option to VIUSettings
1 parent bab1135 commit 763198a

6 files changed

Lines changed: 118 additions & 17 deletions

File tree

Assets/HTC.UnityPlugin/VRModule/Modules/Editor/WaveVRModuleEditor.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,22 @@ public WaveVRSymbolRequirementCollection()
219219
},
220220
reqFileNames = new string[] { "wvr.cs" },
221221
});
222+
223+
Add(new SymbolRequirement()
224+
{
225+
symbol = "VIU_WAVEVR_HAND_TRACKING_CHECK",
226+
reqMethods = new SymbolRequirement.ReqMethodInfo[]
227+
{
228+
new SymbolRequirement.ReqMethodInfo()
229+
{
230+
typeName = "Wave.XR.BuildCheck.CheckIfHandTrackingEnabled",
231+
name = "ValidateEnabled",
232+
argTypeNames = new string[0],
233+
bindingAttr = BindingFlags.Public | BindingFlags.Static,
234+
}
235+
},
236+
reqFileNames = new string[] { "WaveXRBuildCheck.cs" },
237+
});
222238
}
223239
}
224240
}

Assets/HTC.UnityPlugin/VRModule/Modules/WaveVRModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override bool shouldActive
5151
get
5252
{
5353
#if (VIU_WAVEXR_ESSENCE_CONTROLLER_MODEL || VIU_WAVEXR_ESSENCE_RENDERMODEL) && UNITY_ANDROID
54-
return true;
54+
return VIUSettings.enableWaveXRRenderModel;
5555
#else
5656
return false;
5757
#endif

Assets/HTC.UnityPlugin/VRModule/Submodules/WaveHandTrackingSubmodule.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public void Fetch()
4343
private GestureActivator gestureActivator = GestureActivator.Default;
4444
private uint leftDeviceIndex = VRModule.INVALID_DEVICE_INDEX;
4545
private uint rightDeviceIndex = VRModule.INVALID_DEVICE_INDEX;
46-
private static WVR_HandTrackerType preferredTrackerType =
47-
VRModuleSettings.enableWaveNaturalHand ? WVR_HandTrackerType.WVR_HandTrackerType_Natural : WVR_HandTrackerType.WVR_HandTrackerType_Electronic;
46+
private static WVR_HandTrackerType preferredTrackerType = WVR_HandTrackerType.WVR_HandTrackerType_Natural;
4847
private static WVR_HandModelType showElectronicHandWithController =
4948
VRModuleSettings.showWaveElectronicHandWithController ?
5049
WVR_HandModelType.WVR_HandModelType_WithController : WVR_HandModelType.WVR_HandModelType_WithoutController;

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/HTC.ViveInputUtility.Editor.asmdef

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "HTC.ViveInputUtility.Editor",
3-
"rootNamespace": "",
43
"references": [
54
"HTC.ViveInputUtility",
65
"HTC.ViveInputUtility.UPMRegistryTool.Editor",
@@ -12,7 +11,13 @@
1211
"Oculus.VR",
1312
"Oculus.VR.Editor",
1413
"Unity.XR.OpenXR",
15-
"Unity.XR.OpenXR.Editor"
14+
"Unity.XR.OpenXR.Editor",
15+
"Wave.XRSDK",
16+
"Wave.XRSDK.Editor",
17+
"Wave.Essence",
18+
"Wave.Essence.Editor",
19+
"Wave.Native",
20+
"Wave.Native.Editor"
1621
],
1722
"includePlatforms": [
1823
"Editor"

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VRPlatformSettings/WaveVRSettings.cs

Lines changed: 87 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public static partial class VIUSettingsEditor
6464
public const string URL_WAVE_VR_PLUGIN = "https://developer.vive.com/resources/knowledgebase/wave-sdk/";
6565
public const string URL_WAVE_VR_6DOF_SUMULATOR_USAGE_PAGE = "https://github.com/ViveSoftware/ViveInputUtility-Unity/wiki/Wave-VR-6-DoF-Controller-Simulator";
6666
private const string WAVE_XR_PACKAGE_NAME = "com.htc.upm.wave.xrsdk";
67+
private const string WAVE_XR_PACKAGE_NATIVE_NAME = "com.htc.upm.wave.native";
68+
private const string WAVE_XR_PACKAGE_ESSENCE_NAME = "com.htc.upm.wave.essence";
6769

6870
public static bool canSupportWaveVR
6971
{
@@ -190,16 +192,16 @@ public override bool support
190192

191193
public override void OnPreferenceGUI()
192194
{
193-
const string title = "WaveVR";
195+
const string title = "Wave XR";
196+
const float wvrToggleWidth = 226f;
194197
if (canSupport)
195198
{
196199
var wasSupported = support;
197-
support = m_foldouter.ShowFoldoutButtonOnToggleEnabled(new GUIContent(title, "VIVE Focus, VIVE Focus Plus"), wasSupported);
200+
support = m_foldouter.ShowFoldoutButtonOnToggleEnabled(new GUIContent(title, "VIVE Focus, VIVE Flow"), wasSupported);
198201
s_symbolChanged |= wasSupported != support;
199202
}
200203
else
201204
{
202-
const float wvrToggleWidth = 226f;
203205
GUILayout.BeginHorizontal();
204206
Foldouter.ShowFoldoutBlank();
205207

@@ -256,27 +258,100 @@ public override void OnPreferenceGUI()
256258
EditorGUI.indentLevel += 2;
257259

258260
EditorGUILayout.BeginHorizontal();
261+
{
262+
EditorGUIUtility.labelWidth = 230;
263+
var style = new GUIStyle(GUI.skin.textField) { alignment = TextAnchor.MiddleLeft };
264+
VIUSettings.waveVRAndroidManifestPath = EditorGUILayout.DelayedTextField(new GUIContent("Customized AndroidManifest Path:", "Default path: " + defaultAndroidManifestPath),
265+
VIUSettings.waveVRAndroidManifestPath, style);
259266

260-
EditorGUIUtility.labelWidth = 230;
261-
var style = new GUIStyle(GUI.skin.textField) { alignment = TextAnchor.MiddleLeft };
262-
VIUSettings.waveVRAndroidManifestPath = EditorGUILayout.DelayedTextField(new GUIContent("Customized AndroidManifest Path:", "Default path: " + defaultAndroidManifestPath),
263-
VIUSettings.waveVRAndroidManifestPath, style);
264-
if (GUILayout.Button("Open", new GUILayoutOption[] { GUILayout.Width(44), GUILayout.Height(18) }))
267+
s_guiChanged |= EditorGUI.EndChangeCheck();
268+
if (GUILayout.Button("Open", new GUILayoutOption[] { GUILayout.Width(44), GUILayout.Height(18) }))
269+
{
270+
VIUSettings.waveVRAndroidManifestPath = EditorUtility.OpenFilePanel("Select AndroidManifest.xml", string.Empty, "xml");
271+
}
272+
EditorGUI.BeginChangeCheck();
273+
}
274+
EditorGUILayout.EndHorizontal();
275+
276+
EditorGUILayout.BeginHorizontal();
265277
{
266-
VIUSettings.waveVRAndroidManifestPath = EditorUtility.OpenFilePanel("Select AndroidManifest.xml", string.Empty, "xml");
278+
if (!string.IsNullOrEmpty(VIUSettings.waveVRAndroidManifestPath) && !File.Exists(VIUSettings.waveVRAndroidManifestPath))
279+
{
280+
EditorGUILayout.HelpBox("File does not existed!", MessageType.Warning);
281+
}
267282
}
283+
EditorGUILayout.EndHorizontal();
268284

285+
const string enableWaveXRRenderModelTitle = "Enable Wave XR Render Model";
286+
EditorGUILayout.BeginHorizontal();
287+
#if VIU_WAVEXR_ESSENCE_CONTROLLER_MODEL || VIU_WAVEXR_ESSENCE_RENDERMODEL
288+
VIUSettings.enableWaveXRRenderModel = EditorGUILayout.ToggleLeft(new GUIContent(enableWaveXRRenderModelTitle, VIUSettings.ENABLE_WAVE_XR_RENDER_MODEL_TOOLTIP), VIUSettings.enableWaveXRRenderModel);
289+
#else
290+
GUI.enabled = false;
291+
EditorGUILayout.ToggleLeft(new GUIContent(enableWaveXRRenderModelTitle, VIUSettings.ENABLE_WAVE_XR_RENDER_MODEL_TOOLTIP + ". Required Wave XR Plugin Essence"), false, GUILayout.ExpandWidth(true));
292+
GUI.enabled = true;
293+
294+
s_guiChanged |= EditorGUI.EndChangeCheck();
295+
if (GUILayout.Button(new GUIContent("Add Wave XR Plugin Essence", "Add " + WAVE_XR_PACKAGE_NAME + " to Package Manager"), GUILayout.ExpandWidth(false)))
296+
{
297+
if (!ManifestUtils.CheckRegistryExists(RegistryToolSettings.Instance().Registry))
298+
{
299+
ManifestUtils.AddRegistry(RegistryToolSettings.Instance().Registry);
300+
}
301+
302+
if (!PackageManagerHelper.IsPackageInList(WAVE_XR_PACKAGE_ESSENCE_NAME))
303+
{
304+
PackageManagerHelper.AddToPackageList(WAVE_XR_PACKAGE_ESSENCE_NAME);
305+
}
306+
307+
VIUProjectSettings.Instance.isInstallingWaveXRPlugin = true;
308+
}
269309
EditorGUI.BeginChangeCheck();
310+
#endif
270311
EditorGUILayout.EndHorizontal();
271312

313+
const string enableWaveHandTrackingTitle = "Enable Wave Hand Tracking";
272314
EditorGUILayout.BeginHorizontal();
273-
274-
if (!string.IsNullOrEmpty(VIUSettings.waveVRAndroidManifestPath) && !File.Exists(VIUSettings.waveVRAndroidManifestPath))
315+
#if VIU_WAVEVR_HAND_TRACKING_CHECK
275316
{
276-
EditorGUILayout.HelpBox("File does not existed!", MessageType.Warning);
317+
var supported = Wave.XR.BuildCheck.CheckIfHandTrackingEnabled.ValidateEnabled() && VRModuleSettings.activateWaveHandTrackingSubmodule;
318+
var shouldSupport = EditorGUILayout.ToggleLeft(new GUIContent(enableWaveHandTrackingTitle), supported);
319+
if (supported != shouldSupport)
320+
{
321+
Wave.XR.BuildCheck.CheckIfHandTrackingEnabled.PerformAction(shouldSupport);
322+
VRModuleSettings.activateWaveHandTrackingSubmodule = shouldSupport;
323+
}
277324
}
325+
#else
326+
GUI.enabled = false;
327+
EditorGUILayout.ToggleLeft(new GUIContent(enableWaveHandTrackingTitle, "Wave XR Plugin Essence required."), false, GUILayout.ExpandWidth(true));
328+
GUI.enabled = true;
278329

330+
s_guiChanged |= EditorGUI.EndChangeCheck();
331+
if (GUILayout.Button(new GUIContent("Update Wave XR Plugin", "Update " + WAVE_XR_PACKAGE_NAME + " to lateast version"), GUILayout.ExpandWidth(false)))
332+
{
333+
if (!ManifestUtils.CheckRegistryExists(RegistryToolSettings.Instance().Registry))
334+
{
335+
ManifestUtils.AddRegistry(RegistryToolSettings.Instance().Registry);
336+
}
337+
338+
if (PackageManagerHelper.IsPackageInList(WAVE_XR_PACKAGE_ESSENCE_NAME))
339+
{
340+
PackageManagerHelper.AddToPackageList(WAVE_XR_PACKAGE_ESSENCE_NAME);
341+
}
342+
else if (PackageManagerHelper.IsPackageInList(WAVE_XR_PACKAGE_NATIVE_NAME))
343+
{
344+
PackageManagerHelper.AddToPackageList(WAVE_XR_PACKAGE_NATIVE_NAME);
345+
}
346+
else
347+
{
348+
PackageManagerHelper.AddToPackageList(WAVE_XR_PACKAGE_NAME);
349+
}
350+
351+
VIUProjectSettings.Instance.isInstallingWaveXRPlugin = true;
352+
}
279353
EditorGUI.BeginChangeCheck();
354+
#endif
280355
EditorGUILayout.EndHorizontal();
281356

282357
VIUSettings.waveVRAddVirtualArmTo3DoFController = EditorGUILayout.ToggleLeft(new GUIContent("Add Virtual Arm for 3 Dof Controller"), VIUSettings.waveVRAddVirtualArmTo3DoFController);

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/VIUSettingsPartials/WaveVRSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace HTC.UnityPlugin.Vive
66
{
77
public partial class VIUSettings : ScriptableObject
88
{
9+
public const string ENABLE_WAVE_XR_RENDER_MODEL_TOOLTIP = "Use render model proivded by Wave runtime";
10+
911
public const bool ACTIVATE_WAVE_VR_MODULE_DEFAULT_VALUE = true;
1012
public const bool SIMULATE_WAVE_VR_6DOF_CONTROLLER_DEFAULT_VALUE = false;
1113
public const bool WAVE_VR_ADD_VIRTUAL_ARM_TO_3DOF_CONTROLLER = true;
@@ -14,6 +16,7 @@ public partial class VIUSettings : ScriptableObject
1416
public static readonly Vector3 WAVE_VR_VIRTUAL_ARM_EXTENSION_OFFSET_DEFAULT_VALUE = new Vector3(-0.13f, 0.14f, 0.08f);
1517
public static readonly Vector3 WAVE_VR_VIRTUAL_WRIST_REST_POSITION_DEFAULT_VALUE = new Vector3(0.0f, 0.0f, 0.35f);
1618
public static readonly Vector3 WAVE_VR_VIRTUAL_HAND_REST_POSITION_DEFAULT_VALUE = new Vector3(0.0f, 0.0f, 0.05f);
19+
public const bool ENABLE_WAVE_XR_RENDER_MODEL_DEFAULT_VALUE = true;
1720

1821
[SerializeField]
1922
private bool m_activateWaveVRModule = ACTIVATE_WAVE_VR_MODULE_DEFAULT_VALUE;
@@ -33,6 +36,8 @@ public partial class VIUSettings : ScriptableObject
3336
private Vector3 m_waveVRVirtualHandRestPosition = WAVE_VR_VIRTUAL_HAND_REST_POSITION_DEFAULT_VALUE;
3437
[SerializeField]
3538
private string m_waveVRAndroidManifestPath = string.Empty;
39+
[SerializeField, Tooltip(ENABLE_WAVE_XR_RENDER_MODEL_TOOLTIP)]
40+
private bool m_enableWaveXRRenderModel = ENABLE_WAVE_XR_RENDER_MODEL_DEFAULT_VALUE;
3641

3742
public static bool activateWaveVRModule { get { return Instance == null ? ACTIVATE_WAVE_VR_MODULE_DEFAULT_VALUE : s_instance.m_activateWaveVRModule; } set { if (Instance != null) { Instance.m_activateWaveVRModule = value; } } }
3843
public static bool simulateWaveVR6DofController { get { return Instance == null ? SIMULATE_WAVE_VR_6DOF_CONTROLLER_DEFAULT_VALUE : s_instance.m_simulateWaveVR6DoFController; } set { if (Instance != null) { Instance.m_simulateWaveVR6DoFController = value; } } }
@@ -43,5 +48,6 @@ public partial class VIUSettings : ScriptableObject
4348
public static Vector3 waveVRVirtualWristRestPosition { get { return Instance == null ? WAVE_VR_VIRTUAL_WRIST_REST_POSITION_DEFAULT_VALUE : s_instance.m_waveVRVirtualWristRestPosition; } set { if (Instance != null) { Instance.m_waveVRVirtualWristRestPosition = value; } } }
4449
public static Vector3 waveVRVirtualHandRestPosition { get { return Instance == null ? WAVE_VR_VIRTUAL_HAND_REST_POSITION_DEFAULT_VALUE : s_instance.m_waveVRVirtualHandRestPosition; } set { if (Instance != null) { Instance.m_waveVRVirtualHandRestPosition = value; } } }
4550
public static string waveVRAndroidManifestPath { get { return Instance == null ? string.Empty : s_instance.m_waveVRAndroidManifestPath; } set { if (Instance != null) { Instance.m_waveVRAndroidManifestPath = value; } } }
51+
public static bool enableWaveXRRenderModel { get { return Instance == null ? ENABLE_WAVE_XR_RENDER_MODEL_DEFAULT_VALUE : s_instance.m_enableWaveXRRenderModel; } set { if (Instance != null) { Instance.m_enableWaveXRRenderModel = value; } } }
4652
}
4753
}

0 commit comments

Comments
 (0)