Skip to content

Commit 8873903

Browse files
authored
Merge pull request #332 from HodgsonSDAS/ExtensibleInputModule
Merge branch 'master' into ExtensibleInputModule & Perf optimizations
2 parents f2ff449 + 240e85e commit 8873903

File tree

16 files changed

+280
-157
lines changed

16 files changed

+280
-157
lines changed

Assets/HoloToolkit/Input/Scripts/Cursor/Cursor.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,6 @@ public virtual void OnInputEnabled()
345345
/// <param name="eventData"></param>
346346
public virtual void OnInputUp(InputEventData eventData)
347347
{
348-
if (IsInputSourceDown == false)
349-
{
350-
return;
351-
}
352348
IsInputSourceDown = false;
353349
}
354350

Assets/HoloToolkit/Input/Scripts/Gaze/GazeManager.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ public class GazeManager : Singleton<GazeManager>
9292
/// </summary>
9393
public PointerEventData UnityUIPointerEvent { get; private set; }
9494

95+
/// <summary>
96+
/// Cached results of racast results.
97+
/// </summary>
98+
private List<RaycastResult> raycastResultList = new List<RaycastResult>();
99+
95100
protected override void Awake()
96101
{
97102
base.Awake();
@@ -171,14 +176,12 @@ private GameObject RaycastPhysics()
171176
// If there is only one priority, don't prioritize
172177
if (RaycastLayerMasks.Length == 1)
173178
{
174-
IsGazingAtObject = Physics.Raycast(GazeOrigin, GazeNormal, out hitInfo, MaxGazeCollisionDistance,
175-
RaycastLayerMasks[0]);
179+
IsGazingAtObject = Physics.Raycast(GazeOrigin, GazeNormal, out hitInfo, MaxGazeCollisionDistance, RaycastLayerMasks[0]);
176180
}
177181
else
178182
{
179183
// Raycast across all layers and prioritize
180-
RaycastHit? hit =
181-
PrioritizeHits(Physics.RaycastAll(new Ray(GazeOrigin, GazeNormal), MaxGazeCollisionDistance, -1));
184+
RaycastHit? hit = PrioritizeHits(Physics.RaycastAll(new Ray(GazeOrigin, GazeNormal), MaxGazeCollisionDistance, -1));
182185

183186
IsGazingAtObject = hit.HasValue;
184187
if (IsGazingAtObject)
@@ -217,7 +220,7 @@ private void RaycastUnityUI()
217220
UnityUIPointerEvent.position = cursorScreenPos;
218221

219222
// Graphics raycast
220-
List<RaycastResult> raycastResultList = new List<RaycastResult>();
223+
raycastResultList.Clear();
221224
EventSystem.current.RaycastAll(UnityUIPointerEvent, raycastResultList);
222225
RaycastResult uiRaycastResult = FindFirstRaycastInLayermasks(raycastResultList, RaycastLayerMasks);
223226
UnityUIPointerEvent.pointerCurrentRaycast = uiRaycastResult;

Assets/HoloToolkit/Input/Scripts/HandGuidance.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ private void RemoveTrackedHand(InteractionSourceState hand)
159159

160160
protected override void OnDestroy()
161161
{
162-
base.OnDestroy();
163-
164162
InteractionManager.SourceLost -= InteractionManager_SourceLost;
165163
InteractionManager.SourceUpdated -= InteractionManager_SourceUpdated;
166164
InteractionManager.SourceReleased -= InteractionManager_SourceReleased;
165+
166+
base.OnDestroy();
167167
}
168168
}
169169
}

Assets/HoloToolkit/Input/Scripts/InputManager.cs

Lines changed: 149 additions & 73 deletions
Large diffs are not rendered by default.

Assets/HoloToolkit/Input/Tests/Scripts/TestButton.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class TestButton : MonoBehaviour, IInputClickHandler, IFocusable
2020
public float ToolTipDelayTime = 0.5f;
2121

2222
[SerializeField]
23-
protected Animator ButtonAnimator = null;
23+
protected Animator ButtonAnimator;
2424

2525
private static int focusedButtonId;
2626
private static int selectedButtonId;
@@ -32,6 +32,8 @@ public class TestButton : MonoBehaviour, IInputClickHandler, IFocusable
3232

3333
public bool EnableActivation = true;
3434

35+
private AnimatorControllerParameter[] animatorHashes;
36+
3537
private bool focused;
3638
public bool Focused
3739
{
@@ -144,7 +146,11 @@ public void DehydrateButton()
144146
{
145147
if (ButtonAnimator != null && ButtonAnimator.isInitialized)
146148
{
147-
var animatorHashes = ButtonAnimator.parameters;
149+
if (animatorHashes == null)
150+
{
151+
animatorHashes = ButtonAnimator.parameters;
152+
}
153+
148154
for (int i = 0; i < animatorHashes.Length; i++)
149155
{
150156
if (animatorHashes[i].nameHash == deHydrateButtonId)
@@ -164,7 +170,11 @@ private void UpdateButtonAnimation()
164170
{
165171
if (ButtonAnimator != null && ButtonAnimator.gameObject.activeInHierarchy)
166172
{
167-
var animatorHashes = ButtonAnimator.parameters;
173+
if (animatorHashes == null)
174+
{
175+
animatorHashes = ButtonAnimator.parameters;
176+
}
177+
168178
for (int i = 0; i < animatorHashes.Length; i++)
169179
{
170180
if (animatorHashes[i].nameHash == focusedButtonId)

Assets/HoloToolkit/Sharing/Tests/CustomMessages.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
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;
5+
using System.Collections.Generic;
46
using HoloToolkit.Sharing;
57
using HoloToolkit.Unity;
6-
using System.Collections.Generic;
78
using UnityEngine;
89

910
public class CustomMessages : Singleton<CustomMessages>
@@ -21,7 +22,7 @@ public enum TestMessageID : byte
2122

2223
public enum UserMessageChannels
2324
{
24-
Anchors = MessageChannel.UserMessageChannelStart,
25+
Anchors = MessageChannel.UserMessageChannelStart
2526
}
2627

2728
/// <summary>
@@ -58,7 +59,7 @@ void Start()
5859
SharingStage.Instance.SharingManagerConnected += SharingManagerConnected;
5960
}
6061

61-
private void SharingManagerConnected(object sender, System.EventArgs e)
62+
private void SharingManagerConnected(object sender, EventArgs e)
6263
{
6364
InitializeMessageHandlers();
6465
}
@@ -84,7 +85,7 @@ void InitializeMessageHandlers()
8485
connectionAdapter.MessageReceivedCallback += OnMessageReceived;
8586

8687
// Cache the local user ID
87-
this.localUserID = SharingStage.Instance.Manager.GetLocalUser().GetID();
88+
localUserID = SharingStage.Instance.Manager.GetLocalUser().GetID();
8889

8990
for (byte index = (byte)TestMessageID.HeadTransform; index < (byte)TestMessageID.Max; index++)
9091
{
@@ -109,15 +110,15 @@ private NetworkOutMessage CreateMessage(byte MessageType)
109110
public void SendHeadTransform(Vector3 position, Quaternion rotation)
110111
{
111112
// If we are connected to a session, broadcast our head info
112-
if (this.serverConnection != null && this.serverConnection.IsConnected())
113+
if (serverConnection != null && serverConnection.IsConnected())
113114
{
114115
// Create an outgoing network message to contain all the info we want to send
115116
NetworkOutMessage msg = CreateMessage((byte)TestMessageID.HeadTransform);
116117

117118
AppendTransform(msg, position, rotation);
118119

119120
// Send the message as a broadcast, which will cause the server to forward it to all other users in the session.
120-
this.serverConnection.Broadcast(
121+
serverConnection.Broadcast(
121122
msg,
122123
MessagePriority.Immediate,
123124
MessageReliability.UnreliableSequenced,
@@ -127,16 +128,16 @@ public void SendHeadTransform(Vector3 position, Quaternion rotation)
127128

128129
protected override void OnDestroy()
129130
{
130-
base.OnDestroy();
131-
132-
if (this.serverConnection != null)
131+
if (serverConnection != null)
133132
{
134133
for (byte index = (byte)TestMessageID.HeadTransform; index < (byte)TestMessageID.Max; index++)
135134
{
136-
this.serverConnection.RemoveListener(index, this.connectionAdapter);
135+
serverConnection.RemoveListener(index, connectionAdapter);
137136
}
138-
this.connectionAdapter.MessageReceivedCallback -= OnMessageReceived;
137+
connectionAdapter.MessageReceivedCallback -= OnMessageReceived;
139138
}
139+
140+
base.OnDestroy();
140141
}
141142

142143
void OnMessageReceived(NetworkConnection connection, NetworkInMessage msg)

0 commit comments

Comments
 (0)