Skip to content

Commit 9b9bd53

Browse files
fin
1 parent cf6723a commit 9b9bd53

File tree

8 files changed

+58
-76
lines changed

8 files changed

+58
-76
lines changed

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

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Microsoft.MixedReality.Toolkit.Internal.Definitions.InputSystem;
66
using Microsoft.MixedReality.Toolkit.Internal.Definitions.Utilities;
77
using Microsoft.MixedReality.Toolkit.Internal.EventDatum.Input;
8-
using Microsoft.MixedReality.Toolkit.Internal.Extensions;
98
using Microsoft.MixedReality.Toolkit.Internal.Interfaces.Devices;
109
using Microsoft.MixedReality.Toolkit.Internal.Interfaces.InputSystem.Handlers;
1110
using UnityEngine;
@@ -26,17 +25,6 @@ public class ControllerPoseSynchronizer : InputSystemGlobalListener, IMixedReali
2625
/// <inheritdoc />
2726
public Handedness Handedness => handedness;
2827

29-
[SerializeField]
30-
[Tooltip("Disables child GameObjects when the controller source is lost.")]
31-
private bool disableChildren = true;
32-
33-
/// <inheritdoc />
34-
public bool DisableChildren
35-
{
36-
get { return disableChildren; }
37-
set { disableChildren = value; }
38-
}
39-
4028
[SerializeField]
4129
[Tooltip("Should this GameObject clean itself up when it's controller is lost?")]
4230
private bool destroyOnLost = true;
@@ -98,25 +86,7 @@ public MixedRealityInputAction PoseAction
9886
#region IMixedRealitySourcePoseHandler Implementation
9987

10088
/// <inheritdoc />
101-
public virtual void OnSourceDetected(SourceStateEventData eventData)
102-
{
103-
if (Controller == null ||
104-
eventData.Controller == null ||
105-
eventData.Controller.InputSource.SourceId != Controller.InputSource.SourceId)
106-
{
107-
return;
108-
}
109-
110-
if (eventData.Controller.ControllerHandedness == Handedness &&
111-
eventData.Controller.InputSource.SourceId == Controller.InputSource.SourceId)
112-
{
113-
114-
if (disableChildren)
115-
{
116-
gameObject.SetChildrenActive(true);
117-
}
118-
}
119-
}
89+
public virtual void OnSourceDetected(SourceStateEventData eventData) { }
12090

12191
/// <inheritdoc />
12292
public virtual void OnSourceLost(SourceStateEventData eventData)
@@ -133,11 +103,6 @@ public virtual void OnSourceLost(SourceStateEventData eventData)
133103
IsTracked = false;
134104
TrackingState = TrackingState.NotTracked;
135105

136-
if (disableChildren)
137-
{
138-
gameObject.SetChildrenActive(false);
139-
}
140-
141106
if (destroyOnLost)
142107
{
143108
if (Application.isEditor)
@@ -194,7 +159,7 @@ public virtual void OnPositionInputChanged(InputEventData<Vector2> eventData) {
194159
/// <inheritdoc />
195160
public virtual void OnPositionChanged(InputEventData<Vector3> eventData)
196161
{
197-
if (eventData.SourceId == Controller.InputSource.SourceId)
162+
if (eventData.SourceId == Controller?.InputSource.SourceId)
198163
{
199164
if (!UseSourcePoseData &&
200165
PoseAction == eventData.MixedRealityInputAction)
@@ -209,7 +174,7 @@ public virtual void OnPositionChanged(InputEventData<Vector3> eventData)
209174
/// <inheritdoc />
210175
public virtual void OnRotationChanged(InputEventData<Quaternion> eventData)
211176
{
212-
if (eventData.SourceId == Controller.InputSource.SourceId)
177+
if (eventData.SourceId == Controller?.InputSource.SourceId)
213178
{
214179
if (!UseSourcePoseData &&
215180
PoseAction == eventData.MixedRealityInputAction)
@@ -224,7 +189,7 @@ public virtual void OnRotationChanged(InputEventData<Quaternion> eventData)
224189
/// <inheritdoc />
225190
public virtual void OnPoseInputChanged(InputEventData<MixedRealityPose> eventData)
226191
{
227-
if (eventData.SourceId == Controller.InputSource.SourceId)
192+
if (eventData.SourceId == Controller?.InputSource.SourceId)
228193
{
229194
if (!UseSourcePoseData &&
230195
PoseAction == eventData.MixedRealityInputAction)

Assets/MixedRealityToolkit-SDK/Features/UX/Prefabs/Pointers/DefaultControllerPointer.prefab

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,16 @@ MonoBehaviour:
9797
m_EditorClassIdentifier:
9898
handedness: 1
9999
disableChildren: 1
100-
cursorPrefab: {fileID: 1000012072213228, guid: 62718441f3682f94ab10c70a637e014b,
101-
type: 2}
102-
raycastOrigin: {fileID: 0}
103-
pointerOrientation: 0
100+
destroyOnLost: 1
104101
useSourcePoseData: 0
105-
inputSourceAction:
102+
poseAction:
106103
id: 4
107104
description: Pointer Pose
108105
axisConstraint: 7
106+
cursorPrefab: {fileID: 1000012072213228, guid: 62718441f3682f94ab10c70a637e014b,
107+
type: 2}
108+
raycastOrigin: {fileID: 0}
109+
pointerOrientation: 0
109110
activeHoldAction:
110111
id: 0
111112
description: None

Assets/MixedRealityToolkit-SDK/Inspectors/Input/Handlers/ControllerPoseSynchronizerInspector.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ public class ControllerPoseSynchronizerInspector : Editor
1616
private static bool synchronizationSettingsFoldout = true;
1717

1818
private SerializedProperty handedness;
19-
private SerializedProperty disableChildren;
2019
private SerializedProperty useSourcePoseData;
2120
private SerializedProperty poseAction;
2221

22+
protected bool DrawHandednessProperty = true;
23+
2324
protected virtual void OnEnable()
2425
{
2526
synchronizationSettingsFoldout = SessionState.GetBool(SynchronizationSettingsKey, synchronizationSettingsFoldout);
2627
handedness = serializedObject.FindProperty("handedness");
27-
disableChildren = serializedObject.FindProperty("disableChildren");
2828
useSourcePoseData = serializedObject.FindProperty("useSourcePoseData");
2929
poseAction = serializedObject.FindProperty("poseAction");
3030
}
@@ -46,19 +46,21 @@ public override void OnInspectorGUI()
4646

4747
EditorGUI.indentLevel++;
4848

49-
var currentHandedness = (Handedness)handedness.enumValueIndex;
50-
var handIndex = currentHandedness == Handedness.Right ? 1 : 0;
49+
if (DrawHandednessProperty)
50+
{
51+
var currentHandedness = (Handedness)handedness.enumValueIndex;
52+
var handIndex = currentHandedness == Handedness.Right ? 1 : 0;
5153

52-
EditorGUI.BeginChangeCheck();
53-
var newHandednessIndex = EditorGUILayout.Popup(handedness.displayName, handIndex, HandednessLabels);
54+
EditorGUI.BeginChangeCheck();
55+
var newHandednessIndex = EditorGUILayout.Popup(handedness.displayName, handIndex, HandednessLabels);
5456

55-
if (EditorGUI.EndChangeCheck())
56-
{
57-
currentHandedness = newHandednessIndex == 0 ? Handedness.Left : Handedness.Right;
58-
handedness.enumValueIndex = (int)currentHandedness;
57+
if (EditorGUI.EndChangeCheck())
58+
{
59+
currentHandedness = newHandednessIndex == 0 ? Handedness.Left : Handedness.Right;
60+
handedness.enumValueIndex = (int)currentHandedness;
61+
}
5962
}
6063

61-
EditorGUILayout.PropertyField(disableChildren);
6264
EditorGUILayout.PropertyField(useSourcePoseData);
6365

6466
if (!useSourcePoseData.boolValue)

Assets/MixedRealityToolkit-SDK/Inspectors/UX/Pointers/BaseControllerPointerInspector.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class BaseControllerPointerInspector : ControllerPoseSynchronizerInspecto
1818
private SerializedProperty pointerOrientation;
1919
private SerializedProperty requiresHoldAction;
2020

21+
private bool basePointerFoldout = true;
22+
2123
protected bool DrawBasePointerActions = true;
2224

2325
protected override void OnEnable()
@@ -31,28 +33,37 @@ protected override void OnEnable()
3133
pointerAction = serializedObject.FindProperty("pointerAction");
3234
pointerOrientation = serializedObject.FindProperty("pointerOrientation");
3335
requiresHoldAction = serializedObject.FindProperty("requiresHoldAction");
36+
37+
DrawHandednessProperty = false;
3438
}
3539

3640
public override void OnInspectorGUI()
3741
{
42+
base.OnInspectorGUI();
43+
3844
serializedObject.Update();
3945

40-
EditorGUILayout.PropertyField(cursorPrefab);
41-
EditorGUILayout.PropertyField(raycastOrigin);
42-
EditorGUILayout.PropertyField(pointerExtent);
43-
EditorGUILayout.PropertyField(pointerOrientation);
44-
EditorGUILayout.PropertyField(pointerAction);
46+
basePointerFoldout = EditorGUILayout.Foldout(basePointerFoldout, "Base Pointer Settings", true);
4547

46-
if (DrawBasePointerActions)
48+
if (basePointerFoldout)
4749
{
48-
EditorGUILayout.PropertyField(requiresHoldAction);
50+
EditorGUILayout.PropertyField(cursorPrefab);
51+
EditorGUILayout.PropertyField(raycastOrigin);
52+
EditorGUILayout.PropertyField(pointerExtent);
53+
EditorGUILayout.PropertyField(pointerOrientation);
54+
EditorGUILayout.PropertyField(pointerAction);
4955

50-
if (requiresHoldAction.boolValue)
56+
if (DrawBasePointerActions)
5157
{
52-
EditorGUILayout.PropertyField(activeHoldAction);
58+
EditorGUILayout.PropertyField(requiresHoldAction);
59+
60+
if (requiresHoldAction.boolValue)
61+
{
62+
EditorGUILayout.PropertyField(activeHoldAction);
63+
}
5364
}
54-
}
5565

66+
}
5667
serializedObject.ApplyModifiedProperties();
5768
}
5869
}

Assets/MixedRealityToolkit-SDK/StandardAssets/Controllers/DebugControllers/GizmoLeft.prefab

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,10 +1113,9 @@ MonoBehaviour:
11131113
m_Name:
11141114
m_EditorClassIdentifier:
11151115
handedness: 1
1116-
disableChildren: 1
11171116
destroyOnLost: 1
11181117
useSourcePoseData: 1
11191118
poseAction:
1120-
id: 0
1121-
description:
1122-
axisConstraint: 0
1119+
id: 4
1120+
description: Pointer Pose
1121+
axisConstraint: 7

Assets/MixedRealityToolkit-SDK/StandardAssets/Controllers/DebugControllers/GizmoRight.prefab

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,9 @@ MonoBehaviour:
649649
m_Name:
650650
m_EditorClassIdentifier:
651651
handedness: 2
652-
disableChildren: 1
653652
destroyOnLost: 1
654653
useSourcePoseData: 1
655654
poseAction:
656655
id: 0
657-
description:
656+
description: None
658657
axisConstraint: 0

Assets/MixedRealityToolkit/_Core/Devices/BaseController.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ private void TryRenderControllerModel(Type controllerType)
183183
{
184184
var controllerObject = UnityEngine.Object.Instantiate(controllerModel, CameraCache.Main.transform.parent);
185185
controllerObject.name = $"{ControllerHandedness}_{controllerObject.name}";
186+
var poseSynchronizer = controllerObject.GetComponent<IMixedRealityControllerPoseSynchronizer>();
187+
188+
if (poseSynchronizer != null)
189+
{
190+
poseSynchronizer.Controller = this;
191+
}
192+
else
193+
{
194+
Debug.LogWarning($"{controllerObject.name} is missing a IMixedRealityControllerPoseSynchronizer component");
195+
}
186196
}
187197
}
188198
}

Assets/MixedRealityToolkit/_Core/Interfaces/Devices/IMixedRealityControllerPoseSynchronizer.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ public interface IMixedRealityControllerPoseSynchronizer : IMixedRealitySpatialI
1717
/// </summary>
1818
Handedness Handedness { get; }
1919

20-
/// <summary>
21-
/// Disables child <see cref="UnityEngine.GameObject"/>s the controller source is lost.
22-
/// </summary>
23-
bool DisableChildren { get; }
24-
2520
/// <summary>
2621
/// Should this <see cref="UnityEngine.GameObject"/> clean itself up when it's controller is lost?
2722
/// </summary>

0 commit comments

Comments
 (0)