Skip to content

Commit a148923

Browse files
author
Stephen Hodgson
committed
Added a way to delete camera at parent root.
1 parent 5999b2e commit a148923

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Assets/HoloToolkit/Utilities/Scripts/Editor/SceneSettingsWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected override void ApplySettings()
3333
{
3434
if (Values[SceneSetting.AddMixedRealityCamera])
3535
{
36-
DestroyImmediate(Camera.main.gameObject);
36+
DestroyImmediate(Camera.main.gameObject.GetParentRoot());
3737
PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(CameraPrefabGUID)));
3838
}
3939

@@ -92,4 +92,4 @@ protected override void OnEnable()
9292
}
9393
#endregion // Overrides / Event Handlers
9494
}
95-
}
95+
}

Assets/HoloToolkit/Utilities/Scripts/Extensions/GameObjectExtensions.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,17 @@ public static void ApplyLayerCacheRecursively(this GameObject root, Dictionary<G
7373
cache.Remove(child.gameObject);
7474
}
7575
}
76+
77+
public static GameObject GetParentRoot(this GameObject child)
78+
{
79+
if (child.transform.parent == null)
80+
{
81+
return child;
82+
}
83+
else
84+
{
85+
return GetParentRoot(child.transform.parent.gameObject);
86+
}
87+
}
7688
}
77-
}
89+
}

0 commit comments

Comments
 (0)