Skip to content

Commit 2ab513b

Browse files
author
Alexander Seeck
committed
Fixes Destroy calls on Transforms and fixes comparisons of Transforms with GameObjects
1 parent 46001a9 commit 2ab513b

File tree

1 file changed

+16
-15
lines changed
  • Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/BoundingBox

1 file changed

+16
-15
lines changed

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/BoundingBox/BoundingBox.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private enum CardinalAxisType
8080
}
8181

8282
/// <summary>
83-
/// This enum is used interally to define how an object's bounds are calculated in order to fit the boundingbox
83+
/// This enum is used internally to define how an object's bounds are calculated in order to fit the boundingbox
8484
/// to it.
8585
/// </summary>
8686
private enum BoundsCalculationMethod
@@ -297,7 +297,7 @@ public bool IsActive
297297
private HandleType currentHandleType;
298298
#endregion Private Properties
299299

300-
#region Monobehaviour Methods
300+
#region MonoBehaviour Methods
301301
private void Start()
302302
{
303303
targetObject = this.gameObject;
@@ -327,7 +327,7 @@ private void Update()
327327

328328
UpdateRigHandles();
329329
}
330-
#endregion Monobehaviour Methods
330+
#endregion MonoBehaviour Methods
331331

332332
#region Private Methods
333333
private void CreateRig()
@@ -362,7 +362,7 @@ private void DestroyRig()
362362
{
363363
for (var i = 0; i < balls.Count; i++)
364364
{
365-
Destroy(balls[i]);
365+
Destroy(balls[i].gameObject);
366366
}
367367

368368
balls.Clear();
@@ -372,7 +372,7 @@ private void DestroyRig()
372372
{
373373
for (int i = 0; i < links.Count; i++)
374374
{
375-
Destroy(links[i]);
375+
Destroy(links[i].gameObject);
376376
}
377377

378378
links.Clear();
@@ -382,15 +382,15 @@ private void DestroyRig()
382382
{
383383
for (var i = 0; i < corners.Count; i++)
384384
{
385-
Destroy(corners[i]);
385+
Destroy(corners[i].gameObject);
386386
}
387387

388388
corners.Clear();
389389
}
390390

391391
if (rigRoot != null)
392392
{
393-
Destroy(rigRoot);
393+
Destroy(rigRoot.gameObject);
394394
}
395395
}
396396

@@ -496,7 +496,7 @@ private void ScaleByHandle(Vector3 newHandlePosition)
496496
targetObject.transform.localScale = newScale;
497497
}
498498

499-
private Vector3 GetRotationAxis(GameObject handle)
499+
private Vector3 GetRotationAxis(Transform handle)
500500
{
501501
for (int i = 0; i < balls.Count; ++i)
502502
{
@@ -926,10 +926,10 @@ private void ResetHandleVisibility()
926926
SetHiddenHandles();
927927
}
928928

929-
private void ShowOneHandle(GameObject handle)
929+
private void ShowOneHandle(Transform handle)
930930
{
931931
//turn off all balls
932-
if (balls != null)
932+
if (ballRenderers != null)
933933
{
934934
for (int i = 0; i < ballRenderers.Count; ++i)
935935
{
@@ -938,7 +938,7 @@ private void ShowOneHandle(GameObject handle)
938938
}
939939

940940
//turn off all corners
941-
if (corners != null)
941+
if (cornerRenderers != null)
942942
{
943943
for (int i = 0; i < cornerRenderers.Count; ++i)
944944
{
@@ -1043,7 +1043,7 @@ private void UpdateRigHandles()
10431043
}
10441044
}
10451045

1046-
private HandleType GetHandleType(GameObject handle)
1046+
private HandleType GetHandleType(Transform handle)
10471047
{
10481048
for (int i = 0; i < balls.Count; ++i)
10491049
{
@@ -1201,15 +1201,16 @@ public void OnInputDown(InputEventData eventData)
12011201
currentInputSource = eventData.InputSource;
12021202
currentPointer = pointer;
12031203
grabbedHandle = grabbedCollider.gameObject;
1204-
currentHandleType = GetHandleType(grabbedHandle);
1205-
currentRotationAxis = GetRotationAxis(grabbedHandle);
1204+
Transform grabbedHandleTransform = grabbedHandle.transform;
1205+
currentHandleType = GetHandleType(grabbedHandleTransform);
1206+
currentRotationAxis = GetRotationAxis(grabbedHandleTransform);
12061207
currentPointer.TryGetPointingRay(out initialGrabRay);
12071208
initialGrabMag = distance;
12081209
initialGrabbedPosition = grabbedHandle.transform.position;
12091210
initialGrabbedCentroid = targetObject.transform.position;
12101211
initialScale = targetObject.transform.localScale;
12111212
pointer.TryGetPointerPosition(out initialGrabPoint);
1212-
ShowOneHandle(grabbedHandle);
1213+
ShowOneHandle(grabbedHandleTransform);
12131214
initialGazePoint = Vector3.zero;
12141215
}
12151216
}

0 commit comments

Comments
 (0)