Skip to content

Commit 3e1e9b2

Browse files
authored
Merge pull request #7096 from thalbern/user/bethalha/bc_examples
Added AppBar support for BoundsControl and fixed configuration bugs
2 parents 440ffe6 + 5689512 commit 3e1e9b2

25 files changed

+631
-187
lines changed

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/BoundsControl.cs

Lines changed: 89 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControl
2424
public class BoundsControl : MonoBehaviour,
2525
IMixedRealitySourceStateHandler,
2626
IMixedRealityFocusChangedHandler,
27-
IMixedRealityFocusHandler
27+
IMixedRealityFocusHandler,
28+
IBoundsTargetProvider
2829
{
2930
#region Serialized Fields and Properties
3031
[SerializeField]
@@ -57,7 +58,6 @@ public GameObject Target
5758

5859
[Tooltip("For complex objects, automatic bounds calculation may not behave as expected. Use an existing Box Collider (even on a child object) to manually determine bounds of bounds control.")]
5960
[SerializeField]
60-
[FormerlySerializedAs("BoxColliderToUse")]
6161
private BoxCollider boundsOverride = null;
6262

6363
/// <summary>
@@ -131,7 +131,11 @@ public BoundsControlActivationType BoundsControlActivation
131131
/// <summary>
132132
/// Check to draw a tether point from the handles to the hand when manipulating.
133133
/// </summary>
134-
public bool DrawTetherWhenManipulating => drawTetherWhenManipulating;
134+
public bool DrawTetherWhenManipulating
135+
{
136+
get => drawTetherWhenManipulating;
137+
set => drawTetherWhenManipulating = value;
138+
}
135139

136140
[SerializeField]
137141
[Tooltip("Add a Collider here if you do not want the handle colliders to interact with another object's collider.")]
@@ -140,7 +144,11 @@ public BoundsControlActivationType BoundsControlActivation
140144
/// <summary>
141145
/// Add a Collider here if you do not want the handle colliders to interact with another object's collider.
142146
/// </summary>
143-
public Collider HandlesIgnoreCollider => handlesIgnoreCollider;
147+
public Collider HandlesIgnoreCollider
148+
{
149+
get => handlesIgnoreCollider;
150+
set => handlesIgnoreCollider = value;
151+
}
144152

145153
[SerializeField]
146154
[Tooltip("Flatten bounds in the specified axis or flatten the smallest one if 'auto' is selected")]
@@ -207,46 +215,71 @@ public Vector3 BoxPadding
207215
/// <summary>
208216
/// Bounds control box display configuration section.
209217
/// </summary>
210-
public BoxDisplayConfiguration BoxDisplayConfiguration => boxDisplayConfiguration;
218+
public BoxDisplayConfiguration BoxDisplayConfiguration
219+
{
220+
get => boxDisplayConfiguration;
221+
set => boxDisplayConfiguration = value;
222+
}
211223

212224
[SerializeField]
213225
[Tooltip("This section defines the links / lines that are drawn between the corners of the control.")]
214226
private LinksConfiguration linksConfiguration;
215227
/// <summary>
216228
/// This section defines the links / lines that are drawn between the corners of the control.
217229
/// </summary>
218-
public LinksConfiguration LinksConfiguration => linksConfiguration;
230+
public LinksConfiguration LinksConfiguration
231+
{
232+
get => linksConfiguration;
233+
set => linksConfiguration = value;
234+
}
219235

220236
[SerializeField]
221237
[Tooltip("Configuration of the scale handles.")]
222238
private ScaleHandlesConfiguration scaleHandlesConfiguration;
223239
/// <summary>
224240
/// Configuration of the scale handles.
225241
/// </summary>
226-
public ScaleHandlesConfiguration ScaleHandlesConfiguration => scaleHandlesConfiguration;
242+
public ScaleHandlesConfiguration ScaleHandlesConfiguration
243+
{
244+
get => scaleHandlesConfiguration;
245+
set => scaleHandlesConfiguration = value;
246+
}
227247

228248
[SerializeField]
229249
[Tooltip("Configuration of the rotation handles.")]
230250
private RotationHandlesConfiguration rotationHandlesConfiguration;
231251
/// <summary>
232252
/// Configuration of the rotation handles.
233253
/// </summary>
234-
public RotationHandlesConfiguration RotationHandles => rotationHandlesConfiguration;
254+
public RotationHandlesConfiguration RotationHandles
255+
{
256+
get => rotationHandlesConfiguration;
257+
set => rotationHandlesConfiguration = value;
258+
}
235259

236260
[SerializeField]
237261
[Tooltip("Configuration for Proximity Effect to scale handles or change materials on proximity.")]
238262
private ProximityEffectConfiguration handleProximityEffectConfiguration;
239263
/// <summary>
240264
/// Configuration for Proximity Effect to scale handles or change materials on proximity.
241265
/// </summary>
242-
public ProximityEffectConfiguration HandleProximityEffectConfiguration => handleProximityEffectConfiguration;
266+
public ProximityEffectConfiguration HandleProximityEffectConfiguration
267+
{
268+
get => handleProximityEffectConfiguration;
269+
set => handleProximityEffectConfiguration = value;
270+
}
243271

244272
[Header("Debug")]
245273
[Tooltip("Debug only. Component used to display debug messages.")]
274+
private TextMesh debugText;
246275
/// <summary>
247276
/// Component used to display debug messages.
248277
/// </summary>
249-
public TextMesh debugText;
278+
public TextMesh DebugText
279+
{
280+
get => debugText;
281+
set => debugText = value;
282+
}
250283

251284
[SerializeField]
252285
[Tooltip("Determines whether to hide GameObjects (i.e handles, links etc) created and managed by this component in the editor")]
@@ -275,31 +308,47 @@ public bool HideElementsInInspector
275308
/// <summary>
276309
/// Event that gets fired when interaction with a rotation handle starts.
277310
/// </summary>
278-
public UnityEvent RotateStarted => rotateStarted;
311+
public UnityEvent RotateStarted
312+
{
313+
get => rotateStarted;
314+
set => rotateStarted = value;
315+
}
279316

280317
[SerializeField]
281318
[Tooltip("Event that gets fired when interaction with a rotation handle stops.")]
282319
private UnityEvent rotateStopped = new UnityEvent();
283320
/// <summary>
284321
/// Event that gets fired when interaction with a rotation handle stops.
285322
/// </summary>
286-
public UnityEvent RotateStopped => rotateStopped;
323+
public UnityEvent RotateStopped
324+
{
325+
get => rotateStopped;
326+
set => rotateStopped = value;
327+
}
287328

288329
[SerializeField]
289330
[Tooltip("Event that gets fired when interaction with a scale handle starts.")]
290331
private UnityEvent scaleStarted = new UnityEvent();
291332
/// <summary>
292333
/// Event that gets fired when interaction with a scale handle starts.
293334
/// </summary>
294-
public UnityEvent ScaleStarted => scaleStarted;
335+
public UnityEvent ScaleStarted
336+
{
337+
get => scaleStarted;
338+
set => scaleStarted = value;
339+
}
295340

296341
[SerializeField]
297342
[Tooltip("Event that gets fired when interaction with a scale handle stops.")]
298343
private UnityEvent scaleStopped = new UnityEvent();
299344
/// <summary>
300345
/// Event that gets fired when interaction with a scale handle stops.
301346
/// </summary>
302-
public UnityEvent ScaleStopped => scaleStopped;
347+
public UnityEvent ScaleStopped
348+
{
349+
get => scaleStopped;
350+
set => scaleStopped = value;
351+
}
303352

304353
#endregion Serialized Fields
305354

@@ -405,6 +454,21 @@ public bool Active
405454

406455
#endregion Public Properties
407456

457+
#region Private Properties
458+
private bool IsInitialized
459+
{
460+
get
461+
{
462+
return scaleHandles != null &&
463+
rotationHandles != null &&
464+
boxDisplay != null &&
465+
links != null &&
466+
proximityEffect != null;
467+
}
468+
}
469+
470+
#endregion
471+
408472
#region Public Methods
409473

410474
/// <summary>
@@ -429,6 +493,11 @@ public void UnhighlightWires()
429493
/// </summary>
430494
public void CreateRig()
431495
{
496+
if (!IsInitialized)
497+
{
498+
return;
499+
}
500+
432501
DestroyRig();
433502
InitializeRigRoot();
434503
InitializeDataStructures();
@@ -784,9 +853,6 @@ private void UpdateBounds()
784853
}
785854
}
786855
}
787-
788-
789-
790856
private bool DoesActivationMatchFocus(FocusEventData eventData)
791857
{
792858
switch (activation)
@@ -856,6 +922,11 @@ private void DestroyRig()
856922

857923
private void UpdateRigVisibilityInInspector()
858924
{
925+
if (!IsInitialized)
926+
{
927+
return;
928+
}
929+
859930
HideFlags desiredFlags = hideElementsInInspector ? HideFlags.HideInHierarchy | HideFlags.HideInInspector : HideFlags.None;
860931
scaleHandles.UpdateVisibilityInInspector(desiredFlags);
861932
links.UpdateVisibilityInInspector(desiredFlags);
@@ -1107,7 +1178,7 @@ private void SetHighlighted(Transform activeHandle)
11071178

11081179
private void ResetVisuals()
11091180
{
1110-
if (currentPointer != null)
1181+
if (currentPointer != null || !IsInitialized)
11111182
{
11121183
return;
11131184
}

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/BoundsControlTypes.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-

1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
24
namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes
35
{
46
/// <summary>

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/BoxDisplay.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
2-
using System;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
45
using UnityEngine;
5-
using UnityEngine.Events;
66

77
namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControl
88
{

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/Configuration/BoxDisplayConfiguration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using UnityEngine;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using UnityEngine;
25
using UnityEngine.Events;
36

47
namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControl

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/Configuration/HandlesBaseConfiguration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using UnityEngine;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using UnityEngine;
25
using UnityEngine.Events;
36

47
namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControl

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/Configuration/LinksConfiguration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-

1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
24
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
35
using UnityEngine;
46
using UnityEngine.Events;

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/Configuration/RotationHandlesConfiguration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
25
using UnityEngine;
36

47
namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControl

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/Configuration/ScaleHandlesConfiguration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-

1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
24
using UnityEngine;
35

46
namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControl

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/HandlesBase.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
2-
using Microsoft.MixedReality.Toolkit.Utilities;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
35
using System;
46
using System.Collections.Generic;
57
using UnityEngine;
6-
using UnityEngine.Events;
78

89
namespace Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControl
910
{

Assets/MixedRealityToolkit.SDK/Experimental/Features/UX/BoundsControl/Visuals/Links.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-

1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
24
using Microsoft.MixedReality.Toolkit.Experimental.UI.BoundsControlTypes;
35
using System.Collections.Generic;
46
using UnityEngine;
@@ -134,7 +136,7 @@ internal void Flatten(ref int[] flattenedHandles)
134136
internal void CreateLinks(RotationHandles rotationHandles, Transform parent, Vector3 currentBoundsExtents)
135137
{
136138
// create links
137-
if (links != null)
139+
if (links != null && config.ShowWireFrame)
138140
{
139141
GameObject link;
140142
Vector3 linkDimensions = GetLinkDimensions(currentBoundsExtents);

0 commit comments

Comments
 (0)