Skip to content

Commit 64593c6

Browse files
authored
Merge pull request #9939 from keveleigh/perf-indirection
Remove calls to .gameObject on GameObjects
2 parents 61c600c + 87a5620 commit 64593c6

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

Assets/MRTK/Core/Utilities/Gltf/Serialization/ConstructGltf.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ private static async Task ConstructMeshAsync(GltfObject gltfObject, GameObject p
507507
{
508508
GltfMesh gltfMesh = gltfObject.meshes[meshId];
509509

510-
var renderer = parent.gameObject.AddComponent<MeshRenderer>();
511-
var filter = parent.gameObject.AddComponent<MeshFilter>();
510+
var renderer = parent.AddComponent<MeshRenderer>();
511+
var filter = parent.AddComponent<MeshFilter>();
512512

513513
if (gltfMesh.primitives.Length == 1)
514514
{

Assets/MRTK/Examples/Demos/EyeTracking/DemoTargetSelections/Scripts/TargetGroupCreatorRadial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private void InstantiateRadialLayoutedTarget(float radius, float viewingDist, in
171171
// Assign parent
172172
_target.transform.SetParent(transform);
173173

174-
_target.gameObject.SetActive(true);
174+
_target.SetActive(true);
175175

176176
// Add it to our list of instantiated targets
177177
instantiatedTargets.Add(_target);

Assets/MRTK/Examples/Demos/EyeTracking/DemoTargetSelections/Scripts/TargetGroupIterator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private void ProceedToNextTarget()
132132

133133
// 2. If "DisableDistractors" is true then let's hide the selected target
134134
if (DeactiveDistractors)
135-
CurrentTarget.gameObject.SetActive(false);
135+
CurrentTarget.SetActive(false);
136136

137137
// 3. Let's update to highlight the new target.
138138
currTargetIndex++;
@@ -205,7 +205,7 @@ private void HighlightTarget()
205205
if (CurrentTarget == null)
206206
ProceedToNextTarget();
207207

208-
CurrentTarget.gameObject.SetActive(true);
208+
CurrentTarget.SetActive(true);
209209
HighlightTarget(highlightColor);
210210
}
211211

Assets/MRTK/Examples/Demos/EyeTracking/DemoVisualizer/Scripts/InputPointerVisualizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private void ResetVis(ref GameObject[] array)
148148
{
149149
for (int i = array.Length - 1; i >= 0; i--)
150150
{
151-
Destroy(array[i].gameObject);
151+
Destroy(array[i]);
152152
}
153153
}
154154
}

Assets/MRTK/SDK/Editor/Inspectors/UX/Interactable/ButtonConfigHelperInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public override void OnInspectorGUI()
159159
if (seeItSayItLabel.activeSelf != seeItSayItLabelActive)
160160
{
161161
seeItSayItLabel.SetActive(seeItSayItLabelActive);
162-
EditorUtility.SetDirty(seeItSayItLabel.gameObject);
162+
EditorUtility.SetDirty(seeItSayItLabel);
163163
}
164164

165165
if (seeItSayItLabel.activeSelf)

Assets/MRTK/SDK/Experimental/Features/Utilities/StabilizationPlaneModifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private void Awake()
176176
#if UNITY_EDITOR
177177
debugMesh = GameObject.CreatePrimitive(PrimitiveType.Quad);
178178
debugMesh.hideFlags |= HideFlags.HideInHierarchy;
179-
debugMesh.gameObject.SetActive(false);
179+
debugMesh.SetActive(false);
180180
debugMeshFilter = debugMesh.GetComponent<MeshFilter>();
181181
#endif
182182

Assets/MRTK/SDK/Features/UX/Scripts/ProgressIndicators/ProgressIndicatorOrbsRotator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private void Update()
181181
for (int index = 0; index < deployedCount; ++index)
182182
{
183183
float acceleratedDegrees = (rotationSpeedRawDegrees * (acceleration + -Mathf.Cos(Mathf.Deg2Rad * angles[index]))) * timeSlice;
184-
orbs[index].gameObject.transform.Rotate(0, 0, acceleratedDegrees);
184+
orbs[index].transform.Rotate(0, 0, acceleratedDegrees);
185185
angles[index] += Mathf.Abs(acceleratedDegrees);
186186

187187
Color orbColor = propertyBlocks[index].GetColor("_Color");

Assets/MRTK/SDK/Features/UX/Scripts/Utilities/PrefabSpawner.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private async Task UpdateSpawnable(float focusEnterTimeOnStart, float tappedTime
9898
{
9999
spawnable.transform.localRotation = Quaternion.identity;
100100
}
101-
spawnable.gameObject.SetActive(false);
101+
spawnable.SetActive(false);
102102
}
103103
if (appearType == AppearType.AppearOnFocusEnter)
104104
{
@@ -112,11 +112,11 @@ private async Task UpdateSpawnable(float focusEnterTimeOnStart, float tappedTime
112112
}
113113
}
114114

115-
spawnable.gameObject.SetActive(true);
115+
spawnable.SetActive(true);
116116

117117
SpawnableActivated(spawnable);
118118

119-
while (spawnable.gameObject.activeSelf)
119+
while (spawnable.activeSelf)
120120
{
121121
if (remainType == RemainType.Timeout)
122122
{
@@ -125,15 +125,15 @@ private async Task UpdateSpawnable(float focusEnterTimeOnStart, float tappedTime
125125
case AppearType.AppearOnTap:
126126
if (Time.unscaledTime - tappedTime >= lifetime)
127127
{
128-
spawnable.gameObject.SetActive(false);
128+
spawnable.SetActive(false);
129129
return;
130130
}
131131

132132
break;
133133
case AppearType.AppearOnFocusEnter:
134134
if (Time.unscaledTime - focusEnterTime >= lifetime)
135135
{
136-
spawnable.gameObject.SetActive(false);
136+
spawnable.SetActive(false);
137137
return;
138138
}
139139

@@ -147,15 +147,15 @@ private async Task UpdateSpawnable(float focusEnterTimeOnStart, float tappedTime
147147
case VanishType.VanishOnFocusExit:
148148
if (!HasFocus)
149149
{
150-
spawnable.gameObject.SetActive(false);
150+
spawnable.SetActive(false);
151151
}
152152

153153
break;
154154

155155
case VanishType.VanishOnTap:
156156
if (!tappedTime.Equals(tappedTimeOnStart))
157157
{
158-
spawnable.gameObject.SetActive(false);
158+
spawnable.SetActive(false);
159159
}
160160

161161
break;
@@ -164,7 +164,7 @@ private async Task UpdateSpawnable(float focusEnterTimeOnStart, float tappedTime
164164
default:
165165
if (!HasFocus && HasVanishDelayElapsed())
166166
{
167-
spawnable.gameObject.SetActive(false);
167+
spawnable.SetActive(false);
168168
}
169169
break;
170170
}
@@ -216,7 +216,7 @@ protected virtual void HandleTap()
216216
{
217217
tappedTime = Time.unscaledTime;
218218

219-
if (spawnable == null || !spawnable.gameObject.activeSelf)
219+
if (spawnable == null || !spawnable.activeSelf)
220220
{
221221
switch (appearType)
222222
{
@@ -230,7 +230,7 @@ protected virtual void HandleTap()
230230
switch (vanishType)
231231
{
232232
case VanishType.VanishOnTap:
233-
spawnable.gameObject.SetActive(false);
233+
spawnable.SetActive(false);
234234
break;
235235
}
236236
}
@@ -240,7 +240,7 @@ private void HandleFocusEnter()
240240
{
241241
focusEnterTime = Time.unscaledTime;
242242

243-
if (spawnable == null || !spawnable.gameObject.activeSelf)
243+
if (spawnable == null || !spawnable.activeSelf)
244244
{
245245
switch (appearType)
246246
{

Assets/MRTK/Tests/PlayModeTests/BaseCursorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public IEnumerator CursorScaling()
402402
// FIRST DISTANCE
403403
float firstAngularScale = 2 * Mathf.Atan2(baseCursor.LocalScale.y * 0.5f, Vector3.Distance(cam.transform.position, baseCursor.transform.position));
404404

405-
cube.gameObject.SetActive(false);
405+
cube.SetActive(false);
406406

407407
yield return new WaitForFixedUpdate();
408408
yield return null;

Assets/MRTK/Tests/PlayModeTests/BoundsControlTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ public IEnumerator ScaleChildTargetMinMax()
902902
const int numHandSteps = 1;
903903

904904
Vector3 initialHandPosition = new Vector3(0, 0, 0.5f);
905-
var frontRightCornerPos = boundsControl.Target.gameObject.transform.Find("rigRoot/corner_3").position; // front right corner is corner 3
905+
var frontRightCornerPos = boundsControl.Target.transform.Find("rigRoot/corner_3").position; // front right corner is corner 3
906906
TestHand hand = new TestHand(Handedness.Right);
907907

908908
// Hands grab object at initial position

0 commit comments

Comments
 (0)