Skip to content

Commit 2c4b9ee

Browse files
committed
Avoided needless new gameobject while constructing tpose debug skeleton
1 parent fd11834 commit 2c4b9ee

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Qualisys/QTM-Unity-Realtime-Streaming/Streaming/RTSkeleton.cs

+6-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class RTSkeleton : MonoBehaviour
2626

2727
private Skeleton mQtmSkeletonCache;
2828
#if DEBUG_SKELETON
29-
private GameObject mTPoseRoot;
29+
private GameObject mDebugSkeletonTPose;
3030
#endif
3131
void Update()
3232
{
@@ -46,12 +46,8 @@ void Update()
4646
mStreamedRootObject = new GameObject(this.SkeletonName);
4747

4848
#if DEBUG_SKELETON
49-
if (mTPoseRoot != null)
50-
GameObject.Destroy(mTPoseRoot);
51-
mTPoseRoot = new GameObject();
5249
mStreamedRootObject.AddComponent<DebugHierarchyRotations>().color = Color.yellow;
5350
#endif
54-
5551
mQTmSegmentIdToGameObject = new Dictionary<uint, GameObject>(mQtmSkeletonCache.Segments.Count);
5652

5753
foreach (var segment in mQtmSkeletonCache.Segments)
@@ -65,9 +61,11 @@ void Update()
6561

6662
mStreamedRootObject.transform.SetParent(this.transform, false);
6763
#if DEBUG_SKELETON
68-
mTPoseRoot = GameObject.Instantiate<GameObject>(mStreamedRootObject.gameObject, this.transform, false);
69-
mTPoseRoot.name = this.SkeletonName + "-TPose";
70-
mTPoseRoot.GetComponent<DebugHierarchyRotations>().color = Color.white;
64+
if (mDebugSkeletonTPose != null)
65+
GameObject.Destroy(mDebugSkeletonTPose);
66+
mDebugSkeletonTPose = GameObject.Instantiate<GameObject>(mStreamedRootObject.gameObject, this.transform, false);
67+
mDebugSkeletonTPose.name = this.SkeletonName + "-TPose";
68+
mDebugSkeletonTPose.GetComponent<DebugHierarchyRotations>().color = Color.white;
7169
#endif
7270
BuildMecanimAvatarFromQtmTPose();
7371

0 commit comments

Comments
 (0)