I recently dragged and placed a prefab into my scene (a building part) and then subsequently deleted this from the scene by clicking on it in the scene view and hitting delete.
This popped up a message saying this would break the instance of the prefab. (I assume as I deleted a child rather than the actual parent); however, this Gameobject was removed entirely from the hierarchy.
Now when I start the game, the object still exists (I can’t actual see it but as it’s a building part I know it follows my mouse until I click the left mouse button to place it on the terrain). Once placed I can jump on and off it and collide with it, but it still does not exist in the hierarchy.
I really want to be able to delete it but I cannot seem to find a way of doing this now it no longer exists in the hierarchy?
I have used the search function on the hierarchy but this shows no results for anything related to the building part.
Has anyone got any experience with this issue or is it a known bug?
The GameObject was hidden in the hierarchy as its hideflag attribute had been changed (for some unknown reason). The following script can be placed into a folder called Editor and placed in your main assets folder. Assets >> Editor.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
[InitializeOnLoad]
public class DeleteObject : Editor {
static DeleteObject() {
List<GameObject> rootObjects = new List<GameObject>();
// get root objects in scene
Scene scene = SceneManager.GetActiveScene();
scene.GetRootGameObjects( rootObjects );
// iterate root objects and do something
for (int i = 0; i < rootObjects.Count; ++i) {
GameObject gameObject = rootObjects*;*