Skip to content

Commit 1576271

Browse files
Merge branch 'mrtk_development' into vNEXT-Revolution
# Conflicts: # Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/DragAndDropHandler.cs
2 parents 8e84d05 + d82c164 commit 1576271

File tree

7 files changed

+77
-111
lines changed

7 files changed

+77
-111
lines changed

Assets/MixedRealityToolkit-SDK/Features/Input/FocusProvider.cs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -252,52 +252,6 @@ private void Update()
252252

253253
#endregion MonoBehaviour Implementation
254254

255-
#region Focus Details by EventData
256-
257-
/// <inheritdoc />
258-
public GameObject GetFocusedObject(BaseInputEventData eventData)
259-
{
260-
Debug.Assert(eventData != null);
261-
if (OverrideFocusedObject != null) { return OverrideFocusedObject; }
262-
263-
IMixedRealityPointer pointer;
264-
return TryGetPointingSource(eventData, out pointer) ? GetFocusedObject(pointer) : null;
265-
}
266-
267-
/// <inheritdoc />
268-
public bool TryGetFocusDetails(BaseInputEventData eventData, out FocusDetails focusDetails)
269-
{
270-
foreach (var pointerData in pointers)
271-
{
272-
if (pointerData.Pointer.InputSourceParent.SourceId == eventData.SourceId)
273-
{
274-
focusDetails = pointerData.Details;
275-
return true;
276-
}
277-
}
278-
279-
focusDetails = default(FocusDetails);
280-
return false;
281-
}
282-
283-
/// <inheritdoc />
284-
public bool TryGetPointingSource(BaseInputEventData eventData, out IMixedRealityPointer pointer)
285-
{
286-
foreach (var pointerData in pointers)
287-
{
288-
if (pointerData.Pointer.InputSourceParent.SourceId == eventData.SourceId)
289-
{
290-
pointer = pointerData.Pointer;
291-
return true;
292-
}
293-
}
294-
295-
pointer = null;
296-
return false;
297-
}
298-
299-
#endregion Focus Details by EventData
300-
301255
#region Focus Details by IMixedRealityPointer
302256

303257
/// <inheritdoc />

Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/DragAndDropHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData even
135135
currentPointer = eventData.Pointer;
136136

137137
FocusDetails focusDetails;
138-
Vector3 initialDraggingPosition = MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(eventData, out focusDetails)
138+
Vector3 initialDraggingPosition = MixedRealityManager.InputSystem.FocusProvider.TryGetFocusDetails(currentPointer, out focusDetails)
139139
? focusDetails.Point
140140
: hostTransform.position;
141141

@@ -201,7 +201,7 @@ private void StartDragging(Vector3 initialDraggingPosition)
201201
// TODO: robertes: Fix push/pop and single-handler model so that multiple HandDraggable components can be active at once.
202202

203203
// Add self as a modal input handler, to get all inputs during the manipulation
204-
MixedRealityToolkit.InputSystem.PushModalInputHandler(gameObject);
204+
MixedRealityManager.InputSystem.PushModalInputHandler(gameObject);
205205

206206
isDragging = true;
207207

@@ -327,7 +327,7 @@ private void StopDragging()
327327
}
328328

329329
// Remove self as a modal input handler
330-
MixedRealityToolkit.InputSystem.PopModalInputHandler();
330+
MixedRealityManager.InputSystem.PopModalInputHandler();
331331

332332
isDragging = false;
333333

Assets/MixedRealityToolkit-SDK/Features/Input/MixedRealityInputManager.cs

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -259,50 +259,77 @@ public override void HandleEvent<T>(BaseEventData eventData, ExecuteEvents.Event
259259
Debug.Assert(eventData != null);
260260
var baseInputEventData = ExecuteEvents.ValidateEventData<BaseInputEventData>(eventData);
261261
Debug.Assert(baseInputEventData != null);
262-
Debug.Assert(baseInputEventData.InputSource != null, $"Failed to find an input source for {baseInputEventData}");
263262
Debug.Assert(!baseInputEventData.used);
264263

264+
if (baseInputEventData.InputSource == null)
265+
{
266+
Debug.LogError($"Failed to find an input source for {baseInputEventData}");
267+
return;
268+
}
269+
265270
// Send the event to global listeners
266271
base.HandleEvent(eventData, eventHandler);
267272

268273
if (baseInputEventData.used)
269274
{
270-
// All global listeners get a chance to see the event, but if any of them marked it used, we stop
271-
// the event from going any further.
275+
// All global listeners get a chance to see the event,
276+
// but if any of them marked it used,
277+
// we stop the event from going any further.
278+
return;
279+
}
280+
281+
if (baseInputEventData.InputSource.Pointers == null)
282+
{
283+
Debug.LogError($"InputSource {baseInputEventData.InputSource.SourceName} doesn't have any registered pointers! Input Sources without pointers should use the GazeProvider's pointer as a default fallback.");
272284
return;
273285
}
274286

275-
GameObject focusedObject = FocusProvider?.GetFocusedObject(baseInputEventData);
287+
var modalEventHandled = false;
276288

277-
// Handle modal input if one exists
278-
if (modalInputStack.Count > 0)
289+
// Get the focused object for each pointer of the event source
290+
for (int i = 0; i < baseInputEventData.InputSource.Pointers.Length; i++)
279291
{
280-
GameObject modalInput = modalInputStack.Peek();
292+
GameObject focusedObject = FocusProvider?.GetFocusedObject(baseInputEventData.InputSource.Pointers[i]);
281293

282-
// If there is a focused object in the hierarchy of the modal handler, start the event bubble there
283-
if (focusedObject != null && modalInput != null && focusedObject.transform.IsChildOf(modalInput.transform))
294+
// Handle modal input if one exists
295+
if (modalInputStack.Count > 0 && !modalEventHandled)
284296
{
285-
if (ExecuteEvents.ExecuteHierarchy(focusedObject, baseInputEventData, eventHandler) && baseInputEventData.used)
297+
GameObject modalInput = modalInputStack.Peek();
298+
299+
if (modalInput != null)
286300
{
287-
return;
301+
modalEventHandled = true;
302+
303+
// If there is a focused object in the hierarchy of the modal handler, start the event bubble there
304+
if (focusedObject != null && focusedObject.transform.IsChildOf(modalInput.transform))
305+
{
306+
if (ExecuteEvents.ExecuteHierarchy(focusedObject, baseInputEventData, eventHandler) && baseInputEventData.used)
307+
{
308+
return;
309+
}
310+
}
311+
// Otherwise, just invoke the event on the modal handler itself
312+
else
313+
{
314+
if (ExecuteEvents.ExecuteHierarchy(modalInput, baseInputEventData, eventHandler) && baseInputEventData.used)
315+
{
316+
return;
317+
}
318+
}
288319
}
289-
}
290-
// Otherwise, just invoke the event on the modal handler itself
291-
else
292-
{
293-
if (ExecuteEvents.ExecuteHierarchy(modalInput, baseInputEventData, eventHandler) && baseInputEventData.used)
320+
else
294321
{
295-
return;
322+
Debug.LogError("ModalInput GameObject reference was null!\nDid this GameObject get destroyed?");
296323
}
297324
}
298-
}
299325

300-
// If event was not handled by modal, pass it on to the current focused object
301-
if (focusedObject != null)
302-
{
303-
if (ExecuteEvents.ExecuteHierarchy(focusedObject, baseInputEventData, eventHandler) && baseInputEventData.used)
326+
// If event was not handled by modal, pass it on to the current focused object
327+
if (focusedObject != null)
304328
{
305-
return;
329+
if (ExecuteEvents.ExecuteHierarchy(focusedObject, baseInputEventData, eventHandler) && baseInputEventData.used)
330+
{
331+
return;
332+
}
306333
}
307334
}
308335

Assets/MixedRealityToolkit-SDK/Features/UX/Scripts/Pointers/BaseControllerPointer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,17 @@ public uint PointerId
190190
}
191191
}
192192

193+
private string pointerName = string.Empty;
194+
193195
/// <inheritdoc />
194196
public string PointerName
195197
{
196-
get { return gameObject.name; }
197-
set { gameObject.name = value; }
198+
get { return pointerName; }
199+
set
200+
{
201+
pointerName = value;
202+
gameObject.name = value;
203+
}
198204
}
199205

200206
/// <inheritdoc />

Assets/MixedRealityToolkit-SDK/Features/Utilities/Solvers/SolverHandler.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ private void Awake()
134134
DeltaTime = 0.0f;
135135

136136
solvers.AddRange(GetComponents<Solver>());
137+
}
137138

139+
private void Start()
140+
{
138141
// TransformTarget overrides TrackedObjectToReference
139142
if (!transformTarget)
140143
{
@@ -166,10 +169,7 @@ private void LateUpdate()
166169

167170
protected void OnDestroy()
168171
{
169-
if (transformWithOffset != null)
170-
{
171-
Destroy(transformWithOffset);
172-
}
172+
DetachFromCurrentTrackedObject();
173173
}
174174

175175
#endregion MonoBehaviour Implementation
@@ -184,19 +184,19 @@ protected override void OnControllerFound()
184184

185185
protected override void OnControllerLost()
186186
{
187-
transformTarget = null;
188-
189-
if (transformWithOffset != null)
190-
{
191-
Destroy(transformWithOffset);
192-
transformWithOffset = null;
193-
}
187+
DetachFromCurrentTrackedObject();
194188
}
195189

196190
/// <summary>
197191
/// Clears the transform target and attaches to the current <see cref="TrackedObjectToReference"/>.
198192
/// </summary>
199193
public void RefreshTrackedObject()
194+
{
195+
DetachFromCurrentTrackedObject();
196+
AttachToNewTrackedObject();
197+
}
198+
199+
protected virtual void DetachFromCurrentTrackedObject()
200200
{
201201
transformTarget = null;
202202

@@ -205,8 +205,6 @@ public void RefreshTrackedObject()
205205
Destroy(transformWithOffset);
206206
transformWithOffset = null;
207207
}
208-
209-
AttachToNewTrackedObject();
210208
}
211209

212210
protected virtual void AttachToNewTrackedObject()

Assets/MixedRealityToolkit/_Core/Inspectors/Profiles/MixedRealityDiagnosticsSystemProfileInspector.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public override void OnInspectorGUI()
4848
GUI.enabled = false;
4949
}
5050

51+
serializedObject.Update();
52+
5153
EditorGUILayout.Space();
5254
EditorGUILayout.LabelField("Diagnostic Visualization Options", EditorStyles.boldLabel);
5355
EditorGUILayout.HelpBox("Diagnostic visualizations can help monitor system resources and performance inside an application.", MessageType.Info);
@@ -59,6 +61,8 @@ public override void OnInspectorGUI()
5961
EditorGUILayout.PropertyField(showCpu);
6062
EditorGUILayout.PropertyField(showFps);
6163
EditorGUILayout.PropertyField(showMemory);
64+
65+
serializedObject.ApplyModifiedProperties();
6266
}
6367
}
6468
}

Assets/MixedRealityToolkit/_Core/Interfaces/InputSystem/IMixedRealityFocusProvider.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,6 @@ public interface IMixedRealityFocusProvider : IMixedRealitySourceStateHandler
3131
/// </summary>
3232
GameObject OverrideFocusedObject { get; set; }
3333

34-
/// <summary>
35-
/// Gets the currently focused object based on specified the event data.
36-
/// </summary>
37-
/// <param name="eventData"></param>
38-
/// <returns>Currently focused <see cref="GameObject"/> for the events input source.</returns>
39-
GameObject GetFocusedObject(BaseInputEventData eventData);
40-
41-
/// <summary>
42-
/// Try to get the focus details based on the specified event data.
43-
/// </summary>
44-
/// <param name="eventData"></param>
45-
/// <param name="focusDetails"></param>
46-
/// <returns>True, if event data pointer input source is registered.</returns>
47-
bool TryGetFocusDetails(BaseInputEventData eventData, out FocusDetails focusDetails);
48-
49-
/// <summary>
50-
/// Try to get the registered pointer source that raised the event.
51-
/// </summary>
52-
/// <param name="eventData"></param>
53-
/// <param name="pointer"></param>
54-
/// <returns>True, if event data's pointer input source is registered.</returns>
55-
bool TryGetPointingSource(BaseInputEventData eventData, out IMixedRealityPointer pointer);
56-
5734
/// <summary>
5835
/// Gets the currently focused object for the pointing source.
5936
/// <para><remarks>If the pointing source is not registered, then the Gaze's Focused <see cref="GameObject"/> is returned.</remarks></para>
@@ -73,7 +50,7 @@ public interface IMixedRealityFocusProvider : IMixedRealitySourceStateHandler
7350
/// Get the Graphic Event Data for the specified pointing source.
7451
/// </summary>
7552
/// <param name="pointer">The pointer who's graphic event data we're looking for.</param>
76-
/// <param name="graphicInputEventData">The graphihc event data for the specified pointer</param>
53+
/// <param name="graphicInputEventData">The graphic event data for the specified pointer</param>
7754
/// <returns>True, if graphic event data exists.</returns>
7855
bool TryGetSpecificPointerGraphicEventData(IMixedRealityPointer pointer, out GraphicInputEventData graphicInputEventData);
7956

0 commit comments

Comments
 (0)