Skip to content

Commit 582d5d2

Browse files
author
lawwong
committed
Update to v1.20.0:
* Changes - Add support for Unity 6 - Fix compile errors & warnnings - Add support for VIVE OpenXR Unity SDK - Now support hand tracking thru Unity XR Hand - Goto PackageManager > install "XR Hands" (com.unity.xr.hands) - Goto ProjectSettings > XR Plug-in Management > OpenXR > Enabled Interaction Profiles > add "VIVE XR Hand Interaction" - Goto ProjectSettings > XR Plug-in Management > OpenXR > OpenXR Feature Groups > enable "Hand Tracking Subsystem" - Tracked hand will identify as VRModuleDeviceModel.UnityXRHandRight/Left - Add support for latest Wave XR plugin - Fix selecting wrong left/right device in some cases - Add support for latest Oculus plugin - Fix tracked hand model not working
2 parents 82e5b46 + 11967fa commit 582d5d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2946
-142
lines changed

Assets/HTC.UnityPlugin/HTC.ViveInputUtility.asmdef

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"Wave.Essence.Controller.Model",
1818
"Unity.InputSystem",
1919
"Unity.XR.OpenXR",
20-
"Wave.XRSDK"
20+
"Wave.XRSDK",
21+
"Unity.XR.Hands"
2122
],
2223
"includePlatforms": [],
2324
"excludePlatforms": [],
@@ -36,6 +37,11 @@
3637
"name": "com.htc.upm.wave.essence",
3738
"expression": "5.4.0",
3839
"define": "VIU_WAVE_ESSENCE_5_4_OR_NEWER"
40+
},
41+
{
42+
"name": "com.unity.xr.hands",
43+
"expression": "",
44+
"define": "VIU_UNITY_XR_HAND"
3945
}
4046
],
4147
"noEngineReferences": false

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ public static void Initialize()
8787
{
8888
if (Active || isApplicationQuitting) { return; }
8989

90+
#if UNITY_6000_0_OR_NEWER
91+
var instances = FindObjectsByType<Pointer3DInputModule>(FindObjectsSortMode.None);
92+
#else
9093
var instances = FindObjectsOfType<Pointer3DInputModule>();
94+
#endif
9195
if (instances.Length > 0)
9296
{
9397
instance = instances[0];
@@ -99,7 +103,11 @@ public static void Initialize()
99103
EventSystem eventSystem = EventSystem.current;
100104
if (eventSystem == null)
101105
{
106+
#if UNITY_6000_0_OR_NEWER
107+
eventSystem = FindFirstObjectByType<EventSystem>();
108+
#else
102109
eventSystem = FindObjectOfType<EventSystem>();
110+
#endif
103111
}
104112
if (eventSystem == null)
105113
{

Assets/HTC.UnityPlugin/Pointer3D/RaycastMethod/GraphicRaycastMethod.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ protected virtual void Reset()
2020
{
2121
if (m_Canvas == null)
2222
{
23+
#if UNITY_6000_0_OR_NEWER
24+
m_Canvas = FindFirstObjectByType<Canvas>();
25+
#else
2326
m_Canvas = FindObjectOfType<Canvas>();
27+
#endif
2428
}
2529
}
2630
#endif

Assets/HTC.UnityPlugin/PoseTracker/Editor/PoseEaserEditor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,23 @@ public override void OnInspectorGUI()
5555
layoutRect.x += layoutRect.width;
5656

5757
layoutRect.width = toggleFieldWidth;
58-
script.easePositionX = EditorGUI.ToggleLeft(layoutRect, "", script.easePositionX);
58+
if (script != null) script.easePositionX = EditorGUI.ToggleLeft(layoutRect, "", script.easePositionX);
5959
layoutRect.x += layoutRect.width;
6060

6161
layoutRect.width = toggleLabelWidth;
6262
EditorGUI.LabelField(layoutRect, "Y");
6363
layoutRect.x += layoutRect.width;
6464

6565
layoutRect.width = toggleFieldWidth;
66-
script.easePositionY = EditorGUI.ToggleLeft(layoutRect, "", script.easePositionY);
66+
if (script != null) script.easePositionY = EditorGUI.ToggleLeft(layoutRect, "", script.easePositionY);
6767
layoutRect.x += layoutRect.width;
6868

6969
layoutRect.width = toggleLabelWidth;
7070
EditorGUI.LabelField(layoutRect, "Z");
7171
layoutRect.x += layoutRect.width;
7272

7373
layoutRect.width = toggleFieldWidth;
74-
script.easePositionZ = EditorGUI.ToggleLeft(layoutRect, "", script.easePositionZ);
74+
if (script != null) script.easePositionZ = EditorGUI.ToggleLeft(layoutRect, "", script.easePositionZ);
7575
layoutRect.x += layoutRect.width;
7676

7777
// ease rotation
@@ -86,23 +86,23 @@ public override void OnInspectorGUI()
8686
layoutRect.x += layoutRect.width;
8787

8888
layoutRect.width = toggleFieldWidth;
89-
script.easeRotationX = EditorGUI.ToggleLeft(layoutRect, "", script.easeRotationX);
89+
if (script != null) script.easeRotationX = EditorGUI.ToggleLeft(layoutRect, "", script.easeRotationX);
9090
layoutRect.x += layoutRect.width;
9191

9292
layoutRect.width = toggleLabelWidth;
9393
EditorGUI.LabelField(layoutRect, "Y");
9494
layoutRect.x += layoutRect.width;
9595

9696
layoutRect.width = toggleFieldWidth;
97-
script.easeRotationY = EditorGUI.ToggleLeft(layoutRect, "", script.easeRotationY);
97+
if (script != null) script.easeRotationY = EditorGUI.ToggleLeft(layoutRect, "", script.easeRotationY);
9898
layoutRect.x += layoutRect.width;
9999

100100
layoutRect.width = toggleLabelWidth;
101101
EditorGUI.LabelField(layoutRect, "Z");
102102
layoutRect.x += layoutRect.width;
103103

104104
layoutRect.width = toggleFieldWidth;
105-
script.easeRotationZ = EditorGUI.ToggleLeft(layoutRect, "", script.easeRotationZ);
105+
if (script != null) script.easeRotationZ = EditorGUI.ToggleLeft(layoutRect, "", script.easeRotationZ);
106106
layoutRect.x += layoutRect.width;
107107

108108
if (EditorGUI.EndChangeCheck())

Assets/HTC.UnityPlugin/PoseTracker/Editor/PoseFreezerEditor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ public override void OnInspectorGUI()
5252
layoutRect.x += layoutRect.width;
5353

5454
layoutRect.width = toggleFieldWidth;
55-
script.freezePositionX = EditorGUI.ToggleLeft(layoutRect, "", script.freezePositionX);
55+
if (script != null) script.freezePositionX = EditorGUI.ToggleLeft(layoutRect, "", script.freezePositionX);
5656
layoutRect.x += layoutRect.width;
5757

5858
layoutRect.width = toggleLabelWidth;
5959
EditorGUI.LabelField(layoutRect, "Y");
6060
layoutRect.x += layoutRect.width;
6161

6262
layoutRect.width = toggleFieldWidth;
63-
script.freezePositionY = EditorGUI.ToggleLeft(layoutRect, "", script.freezePositionY);
63+
if (script != null) script.freezePositionY = EditorGUI.ToggleLeft(layoutRect, "", script.freezePositionY);
6464
layoutRect.x += layoutRect.width;
6565

6666
layoutRect.width = toggleLabelWidth;
6767
EditorGUI.LabelField(layoutRect, "Z");
6868
layoutRect.x += layoutRect.width;
6969

7070
layoutRect.width = toggleFieldWidth;
71-
script.freezePositionZ = EditorGUI.ToggleLeft(layoutRect, "", script.freezePositionZ);
71+
if (script != null) script.freezePositionZ = EditorGUI.ToggleLeft(layoutRect, "", script.freezePositionZ);
7272
layoutRect.x += layoutRect.width;
7373

7474
// freeze rotation
@@ -83,23 +83,23 @@ public override void OnInspectorGUI()
8383
layoutRect.x += layoutRect.width;
8484

8585
layoutRect.width = toggleFieldWidth;
86-
script.freezeRotationX = EditorGUI.ToggleLeft(layoutRect, "", script.freezeRotationX);
86+
if (script != null) script.freezeRotationX = EditorGUI.ToggleLeft(layoutRect, "", script.freezeRotationX);
8787
layoutRect.x += layoutRect.width;
8888

8989
layoutRect.width = toggleLabelWidth;
9090
EditorGUI.LabelField(layoutRect, "Y");
9191
layoutRect.x += layoutRect.width;
9292

9393
layoutRect.width = toggleFieldWidth;
94-
script.freezeRotationY = EditorGUI.ToggleLeft(layoutRect, "", script.freezeRotationY);
94+
if (script != null) script.freezeRotationY = EditorGUI.ToggleLeft(layoutRect, "", script.freezeRotationY);
9595
layoutRect.x += layoutRect.width;
9696

9797
layoutRect.width = toggleLabelWidth;
9898
EditorGUI.LabelField(layoutRect, "Z");
9999
layoutRect.x += layoutRect.width;
100100

101101
layoutRect.width = toggleFieldWidth;
102-
script.freezeRotationZ = EditorGUI.ToggleLeft(layoutRect, "", script.freezeRotationZ);
102+
if (script != null) script.freezeRotationZ = EditorGUI.ToggleLeft(layoutRect, "", script.freezeRotationZ);
103103
layoutRect.x += layoutRect.width;
104104

105105
if (EditorGUI.EndChangeCheck())

Assets/HTC.UnityPlugin/UPMRegistryTool/Editor/Scripts/Utils/SimpleJSON.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public static JSONNode Parse(string aJSON)
567567

568568
stack.Pop();
569569
if (Token.Length > 0 || TokenIsQuoted)
570-
ctx.Add(TokenName, ParseElement(Token.ToString(), TokenIsQuoted));
570+
if (ctx != null) ctx.Add(TokenName, ParseElement(Token.ToString(), TokenIsQuoted));
571571
TokenIsQuoted = false;
572572
TokenName = "";
573573
Token.Length = 0;
@@ -598,7 +598,7 @@ public static JSONNode Parse(string aJSON)
598598
break;
599599
}
600600
if (Token.Length > 0 || TokenIsQuoted)
601-
ctx.Add(TokenName, ParseElement(Token.ToString(), TokenIsQuoted));
601+
if (ctx != null) ctx.Add(TokenName, ParseElement(Token.ToString(), TokenIsQuoted));
602602
TokenIsQuoted = false;
603603
TokenName = "";
604604
Token.Length = 0;

Assets/HTC.UnityPlugin/Utility/Attribute/Editor/CustomOrderedEnumAttributeDrawer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2323
Type displayedEnumType = null;
2424
if (property.propertyType == SerializedPropertyType.Enum)
2525
{
26-
if (attr.overrideEnumType != null && attr.overrideEnumType.IsEnum)
26+
if (attr != null && attr.overrideEnumType != null && attr.overrideEnumType.IsEnum)
2727
{
2828
displayedEnumType = attr.overrideEnumType;
2929
}
@@ -34,7 +34,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
3434
}
3535
else if (property.propertyType == SerializedPropertyType.Integer)
3636
{
37-
if (attr.overrideEnumType != null && attr.overrideEnumType.IsEnum)
37+
if (attr != null && attr.overrideEnumType != null && attr.overrideEnumType.IsEnum)
3838
{
3939
displayedEnumType = attr.overrideEnumType;
4040
}

Assets/HTC.UnityPlugin/Utility/Attribute/Editor/FlagsFromEnumAttributeDrawer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ private bool TryGetEnumInfo(out EnumUtils.EnumDisplayInfo info)
2727
{
2828
var ffeAttribute = attribute as FlagsFromEnumAttribute;
2929

30-
if (ffeAttribute.EnumType == null || !ffeAttribute.EnumType.IsEnum)
30+
if (ffeAttribute != null && (ffeAttribute.EnumType == null || !ffeAttribute.EnumType.IsEnum))
3131
{
3232
info = null;
3333
return false;
3434
}
3535

36-
info = EnumUtils.GetDisplayInfo(ffeAttribute.EnumType);
36+
if (ffeAttribute != null) info = EnumUtils.GetDisplayInfo(ffeAttribute.EnumType);
37+
else info = null;
38+
3739
return info != null;
3840
}
3941

Assets/HTC.UnityPlugin/Utility/Container/Editor/EnumArrayDrawer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
3232
else
3333
{
3434
var target = GetTargetObjectOfProperty(property) as EnumArrayBase;
35-
EditorGUI.LabelField(position, label, new GUIContent(target.ElementType.Name + " cannot be serialized"));
35+
if (target != null) EditorGUI.LabelField(position, label, new GUIContent(target.ElementType.Name + " cannot be serialized"));
3636
}
3737
}
3838
else
3939
{
4040
var target = GetTargetObjectOfProperty(property) as EnumArrayBase;
41+
if (target == null) return;
4142
position.height = EditorGUIUtility.singleLineHeight;
4243

4344
const float btnPadding = 2f;
@@ -111,7 +112,7 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
111112
var target = GetTargetObjectOfProperty(property) as EnumArrayBase;
112113
for (int i = 0, imax = Mathf.Min(arrayLen, target.Length); i < imax; ++i)
113114
{
114-
if (target.IsValidIndex(i + target.MinInt))
115+
if (target != null && target.IsValidIndex(i + target.MinInt))
115116
{
116117
result += verticalSpacing + EditorGUI.GetPropertyHeight(arrayProp.GetArrayElementAtIndex(i), GUIContent.none, true);
117118
}

Assets/HTC.UnityPlugin/Utility/RigidPose.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,11 @@ public static void SetPose(Transform target, RigidPose pose, Transform origin =
158158
public static void SetRigidbodyVelocity(Rigidbody rigidbody, Vector3 from, Vector3 to, float duration)
159159
{
160160
var diffPos = to - from;
161-
if (Mathf.Approximately(diffPos.sqrMagnitude, 0f))
162-
{
163-
rigidbody.velocity = Vector3.zero;
164-
}
165-
else
166-
{
167-
rigidbody.velocity = diffPos / duration;
168-
}
161+
#if UNITY_6000_0_OR_NEWER
162+
rigidbody.linearVelocity = Mathf.Approximately(diffPos.sqrMagnitude, 0f) ? Vector3.zero : (diffPos / duration);
163+
#else
164+
rigidbody.velocity = Mathf.Approximately(diffPos.sqrMagnitude, 0f) ? Vector3.zero : (diffPos / duration);
165+
#endif
169166
}
170167

171168
// proper folloing duration is larger then 0.02 second, depends on the update rate

0 commit comments

Comments
 (0)