Skip to content

Commit e229b68

Browse files
committed
Update to v1.11.0
* New Features - Add compatibility with **Unity 2020.1** - Add support for **Unity XR Platform** (OpenVR, Oculus, and Windows MR) - VIU Settings automatically installs proper XR Loader from **PackageManager** for supported devices - **OpenVR XR Plugin** - **Oculus XR Plugin** - **Windows XR Plugin** - Add support for Oculus controller render model (Requires [Oculus SDK](https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022)) - Add new **ControllerButton.DPadCenter** & **ControllerButton.DPadCenterTouch** - Also change **VIUSettings.virtualDPadDeadZone** default value from 0.15 to **0.25** - This settings is not available in VIU Settings UI yet, but can be manually modified in HTC.UnityPlugin/ViveInputUtility/Resources/**VIUSettings.asset** * Changes - Now use relative path when choosing Oculus Android AndroidManifest.xml file with picker (#175) - Update **ControllerManagerSample** - Fix support for StickyGrabbables - Clean up side cases where updateactivity was needed - Add more button options for laser pointer - Fix typo - Slightly change **ColliderEventCaster**'s behaviour - Now IColliderEventPressUpHandler will be treggered only if IColliderEventPressDownHandler also implemented - This is for aligning IPointerUpHandler and IPointerDownHandler behaviour - Improve **Grabbable** - Now **BasicGrabbable** & **StickyGrabbable** able to accept more then one grab button - Add new property **primaryGrabButton** so it can be specified with VIU ControllerButton - Obsolete property grabButton and add new property **secondaryGrabButton** as a substitute - Note that you must setup **ViveColliderEventCaster** properly to send the specified grab button event - Improve **Teleportable** - Now **Teleportable** able to accept more then one teleport button - Add new property **PrimeryTeleportButton** so it can specify with VIU ControllerButton - Obsolete property teleportButton and add new property **SecondaryTeleportButton** as a substitute - Note that you must setup **ViveRaycaster** properly to send the specified teleport button event - Add new property **TriggeredType** - **ButtonUp** : perform teleport on button press up (default) - **ButtonDown** : perform teleport on button press down - **ButtonClick** : perform teleport on button press up only if pointed object when press down/up are the same - Add new property **RotateToHitObjectFront** - When set to true, teleportation will rotate pivot front to hit object front - Add new property **TeleportToHitObjectPivot** - When set to true, teleportation will move pivot to hit object pivot instead of the hit point - Add new property **UseSteamVRFade** - Only works when [SteamVR Plugin](https://assetstore.unity.com/packages/tools/integration/steamvr-plugin-32647) is installed - When set to false or SteamVR Plugin is not installed, the teleportation will delay for half of fadeDuration without fading effect - This provides an option for developer to implement their custom fading effect in the OnBeforeTeleport event - Add event **OnBeforeTeleport(Teleportable src, RaycastResult hitResult, float delay)** - Emit before fade duration start counting down - Usually delay argument is half of fade duration (0 if fadeDuration is ignored) - Possible usage is to start custom fading effect in this callback - Add event **OnAfterTeleport(Teleportable src, RaycastResult hitResult, float delay)** - Emit after teleportation is performed - Add static event **OnBeforeAnyTeleport(Teleportable src, RaycastResult hitResult, float delay)** - Static version of OnBeforeTeleport - Emit before OnBeforeTeleport - Add static event **OnAfterAnyTeleport(Teleportable src, RaycastResult hitResult, float delay)** - Static version of OnAfterTeleport - Emit before OnAfterTeleport - Add property **AdditionalTeleportRotation** - The rotation value will be multiplied on the target (around pivot) when teleporting - Possible usage is to set the value (according to other input like pad or joystick direction) in the OnBeforeTeleport callback - Add method **AbortTeleport()** - Cancel the teleportation during fading - Possible usage is to abort in the OnBeforeTeleport callback to perform a custom teleportation - Another usage is to interrupt the fade-in effect progress so that the Teleportable able to trigger next teleport event immediatly * Bug Fixes - Fix left Cosmos controller did not bind button X and Y - Fix saving of Oculus Android XML path setting (#175) - Fix applying some recommended settings didn't trigger editor to compile - Fix "recommended settings" button in VIU Settings disappeared after exiting editor play mode
2 parents fcedea8 + c26cdf8 commit e229b68

File tree

203 files changed

+6126
-601
lines changed

Some content is hidden

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

203 files changed

+6126
-601
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VIUProjectSettings.asset.
2626
*.json
2727
*.vrmanifest
2828

29+
!package.json
30+
2931
# Autogenerated VS/MD/Consulo solution and project files
3032
ExportedObj/
3133
.consulo/

Assets/HTC.UnityPlugin/ColliderEvent/ColliderEventCaster.cs

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
1+
//========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
22

33
using HTC.UnityPlugin.Utility;
44
using System.Collections.Generic;
@@ -13,6 +13,8 @@ public interface IColliderEventCaster
1313
Transform transform { get; }
1414
MonoBehaviour monoBehaviour { get; }
1515

16+
IIndexedSetReadOnly<Collider> enteredColliders { get; }
17+
1618
Rigidbody rigid { get; }
1719
}
1820

@@ -68,13 +70,18 @@ public Rigidbody rigid
6870
get { return m_rigid ?? (m_rigid = GetComponent<Rigidbody>()); }
6971
}
7072

73+
public IIndexedSetReadOnly<Collider> enteredColliders
74+
{
75+
get { return stayingColliders.ReadOnly; }
76+
}
77+
7178
public ColliderHoverEventData HoverEventData
7279
{
7380
get { return hoverEventData ?? (hoverEventData = new ColliderHoverEventData(this)); }
7481
protected set { hoverEventData = value; }
7582
}
7683

77-
private bool CannotHandlerDragAnymore(GameObject handler)
84+
private bool CannotHandlDragAnymore(GameObject handler)
7885
{
7986
return !ExecuteEvents.CanHandleEvent<IColliderEventDragStartHandler>(handler);
8087
}
@@ -94,7 +101,7 @@ protected virtual void FixedUpdate()
94101
var eventData = buttonEventDataList[i];
95102
var handlers = GetButtonHandlers(i);
96103

97-
eventData.draggingHandlers.RemoveAll(CannotHandlerDragAnymore);
104+
eventData.draggingHandlers.RemoveAll(CannotHandlDragAnymore);
98105

99106
if (!eventData.isPressed) { continue; }
100107

@@ -162,7 +169,7 @@ protected virtual void Update()
162169
var eventData = buttonEventDataList[i];
163170
var handlers = GetButtonHandlers(i);
164171

165-
eventData.draggingHandlers.RemoveAll(CannotHandlerDragAnymore);
172+
eventData.draggingHandlers.RemoveAll(CannotHandlDragAnymore);
166173

167174
// process button press
168175
if (!eventData.isPressed)
@@ -224,7 +231,7 @@ protected virtual void Update()
224231
for (int i = 0, imax = axisEventDataList.Count; i < imax; ++i)
225232
{
226233
var eventData = axisEventDataList[i];
227-
234+
228235
if ((eventData.v4 = eventData.GetDelta()) == Vector4.zero) { continue; }
229236

230237
var handlers = GetAxisHandlers(i);
@@ -248,56 +255,54 @@ protected void ProcessPressDown(ColliderButtonEventData eventData, ButtonHandler
248255
eventData.pressPosition = transform.position;
249256
eventData.pressRotation = transform.rotation;
250257

258+
for (int i = stayingColliders.Count - 1; i >= 0; --i)
259+
{
260+
if (stayingColliders[i] != null) { eventData.pressedRawObjects.AddUnique(stayingColliders[i].gameObject); }
261+
}
262+
263+
// press down
264+
GetEventHandlersFromHoveredColliders<IColliderEventPressDownHandler>(eventData.pressedHandlers, handlers.pressDownHandlers);
251265
// click start
252266
GetEventHandlersFromHoveredColliders<IColliderEventClickHandler>(eventData.clickingHandlers);
253-
// press down
254-
GetEventHandlersFromHoveredColliders<IColliderEventPressDownHandler>(handlers.pressDownHandlers);
255267
// drag start
256268
GetEventHandlersFromHoveredColliders<IColliderEventDragStartHandler>(eventData.draggingHandlers, handlers.dragStartHandlers);
257269
}
258270

259271
protected void ProcessPressing(ColliderButtonEventData eventData, ButtonHandlers handlers)
260272
{
261273
// dragging
262-
for (int i = eventData.draggingHandlers.Count - 1; i >= 0; --i)
263-
{
264-
handlers.dragUpdateHandlers.Add(eventData.draggingHandlers[i]);
265-
}
274+
handlers.dragUpdateHandlers.AddRange(eventData.draggingHandlers);
266275
}
267276

268277
protected void ProcessPressUp(ColliderButtonEventData eventData, ButtonHandlers handlers)
269278
{
279+
IndexedSet<GameObject> tmp;
270280
eventData.isPressed = false;
271281

282+
tmp = eventData.lastPressedRawObjects;
283+
eventData.lastPressedRawObjects = eventData.pressedRawObjects;
284+
eventData.pressedRawObjects = tmp;
285+
272286
// press up
273-
GetEventHandlersFromHoveredColliders<IColliderEventPressUpHandler>(handlers.pressUpHandlers);
287+
handlers.pressUpHandlers.AddRange(eventData.pressedHandlers);
288+
289+
tmp = eventData.lastPressedHandlers;
290+
eventData.lastPressedHandlers = eventData.pressedHandlers;
291+
eventData.pressedHandlers = tmp;
292+
274293
// drag end
275-
for (int i = eventData.draggingHandlers.Count - 1; i >= 0; --i)
276-
{
277-
handlers.dragEndHandlers.Add(eventData.draggingHandlers[i]);
278-
}
294+
handlers.dragEndHandlers.AddRange(eventData.draggingHandlers);
279295
// drop
280-
if (eventData.draggingHandlers.Count > 0)
296+
if (eventData.isDragging)
281297
{
282298
GetEventHandlersFromHoveredColliders<IColliderEventDropHandler>(handlers.dropHandlers);
283299
}
284-
// click end (execute only if pressDown handler and pressUp handler are the same)
285300

286-
for (int i = stayingColliders.Count - 1; i >= 0; --i)
287-
{
288-
var collider = stayingColliders[i];
289-
290-
if (collider == null) { continue; }
291-
292-
var handler = ExecuteEvents.GetEventHandler<IColliderEventClickHandler>(collider.gameObject);
293-
294-
if (ReferenceEquals(handler, null)) { continue; }
295-
296-
if (!eventData.clickingHandlers.Remove(handler)) { continue; }
297-
298-
handlers.clickHandlers.Add(handler);
299-
}
301+
// click end (execute only if pressDown handler and pressUp handler are the same)
302+
GetMatchedEventHandlersFromHoveredColliders<IColliderEventClickHandler>(h => eventData.clickingHandlers.Remove(h), handlers.clickHandlers);
300303

304+
eventData.pressedRawObjects.Clear();
305+
eventData.pressedHandlers.Clear();
301306
eventData.clickingHandlers.Clear();
302307
eventData.draggingHandlers.Clear();
303308
}
@@ -320,7 +325,7 @@ private void CleanUp()
320325
var eventData = buttonEventDataList[i];
321326
var handlers = GetButtonHandlers(i);
322327

323-
eventData.draggingHandlers.RemoveAll(CannotHandlerDragAnymore);
328+
eventData.draggingHandlers.RemoveAll(CannotHandlDragAnymore);
324329

325330
if (eventData.isPressed)
326331
{
@@ -331,10 +336,6 @@ private void CleanUp()
331336
{
332337
handlers.pressExitHandlers.Add(eventData.pressEnteredObjects[j]);
333338
}
334-
335-
eventData.clickingHandlers.Clear();
336-
eventData.draggingHandlers.Clear();
337-
eventData.pressEnteredObjects.Clear();
338339
}
339340

340341
// exit all
@@ -362,7 +363,12 @@ private AxisHandlers GetAxisHandlers(int i)
362363
return axisEventHanderList[i] ?? (axisEventHanderList[i] = new AxisHandlers());
363364
}
364365

365-
private void GetEventHandlersFromHoveredColliders<T>(params IList<GameObject>[] appendHandlers) where T : IEventSystemHandler
366+
private void GetEventHandlersFromHoveredColliders<T>(IList<GameObject> appendHandler, IList<GameObject> appendHandler2 = null) where T : IEventSystemHandler
367+
{
368+
GetMatchedEventHandlersFromHoveredColliders<T>(null, appendHandler, appendHandler2);
369+
}
370+
371+
private void GetMatchedEventHandlersFromHoveredColliders<T>(System.Predicate<GameObject> match, IList<GameObject> appendHandler, IList<GameObject> appendHandler2 = null) where T : IEventSystemHandler
366372
{
367373
for (int i = stayingColliders.Count - 1; i >= 0; --i)
368374
{
@@ -376,10 +382,10 @@ private void GetEventHandlersFromHoveredColliders<T>(params IList<GameObject>[]
376382

377383
if (!s_gos.Add(handler.GetInstanceID())) { continue; }
378384

379-
foreach (var handlers in appendHandlers)
380-
{
381-
handlers.Add(handler);
382-
}
385+
if (match != null && !match(handler)) { continue; }
386+
387+
if (appendHandler != null) { appendHandler.Add(handler); }
388+
if (appendHandler2 != null) { appendHandler2.Add(handler); }
383389
}
384390

385391
s_gos.Clear();
@@ -420,6 +426,8 @@ private void ExecuteAllEvents()
420426

421427
private void ExcuteHandlersEvents<T>(List<GameObject> handlers, BaseEventData eventData, ExecuteEvents.EventFunction<T> functor) where T : IEventSystemHandler
422428
{
429+
if (handlers.Count == 0) { return; }
430+
423431
for (int i = handlers.Count - 1; i >= 0; --i)
424432
{
425433
ExecuteEvents.Execute(handlers[i], eventData, functor);

Assets/HTC.UnityPlugin/ColliderEvent/ColliderEventData.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
1+
//========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
22

33
using HTC.UnityPlugin.Utility;
44
using UnityEngine;
@@ -45,13 +45,18 @@ public abstract class ColliderButtonEventData : ColliderEventData
4545
{
4646
public enum InputButton
4747
{
48+
None = -1,
4849
Trigger,
4950
PadOrStick,
5051
GripOrHandTrigger,
5152
FunctionKey,
5253
}
5354

54-
public IndexedSet<GameObject> pressEnteredObjects = new IndexedSet<GameObject>();
55+
public IndexedSet<GameObject> pressEnteredObjects = new IndexedSet<GameObject>(); // Includes full entered objects hierorchy
56+
public IndexedSet<GameObject> pressedRawObjects = new IndexedSet<GameObject>();
57+
public IndexedSet<GameObject> lastPressedRawObjects = new IndexedSet<GameObject>();
58+
public IndexedSet<GameObject> pressedHandlers = new IndexedSet<GameObject>();
59+
public IndexedSet<GameObject> lastPressedHandlers = new IndexedSet<GameObject>();
5560
public IndexedSet<GameObject> draggingHandlers = new IndexedSet<GameObject>();
5661
public IndexedSet<GameObject> clickingHandlers = new IndexedSet<GameObject>();
5762

@@ -90,7 +95,7 @@ public enum Dim
9095
D3,
9196
D4,
9297
}
93-
98+
9499
// raw delta values
95100
private float m_x;
96101
private float m_y;

Assets/HTC.UnityPlugin/ColliderEvent/ColliderEventInterfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
1+
//========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
22

33
using UnityEngine.EventSystems;
44

Assets/HTC.UnityPlugin/ColliderEvent/ExecuteColliderEvents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
1+
//========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
22

33
using UnityEngine.EventSystems;
44

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "HTC.ViveInputUtility",
3+
"references": [
4+
"Unity.XR.Management",
5+
"SteamVR",
6+
"Oculus.Avatar",
7+
"Oculus.VR",
8+
"Oculus.Platform",
9+
"UnityEngine.SpatialTracking"
10+
],
11+
"includePlatforms": [],
12+
"excludePlatforms": [],
13+
"allowUnsafeCode": false,
14+
"overrideReferences": false,
15+
"precompiledReferences": [],
16+
"autoReferenced": true,
17+
"defineConstraints": [],
18+
"versionDefines": [],
19+
"noEngineReferences": false
20+
}

Assets/HTC.UnityPlugin/HTC.ViveInputUtility.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/HTC.UnityPlugin/Pointer3D/ExecutePointer3DEvents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
1+
//========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
22

33
using UnityEngine.EventSystems;
44

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DEventData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
1+
//========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
22

33
using UnityEngine;
44
using UnityEngine.EventSystems;

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DEventInterfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
1+
//========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
22

33
using UnityEngine.EventSystems;
44

0 commit comments

Comments
 (0)