Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by basil3 · Aug 22, 2018 at 08:38 PM · bughierarchydeletedeleted

Gameobject in scene but missing in hierarchy?

Hi,

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?

Ste.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NoDumbQuestion · Aug 23, 2018 at 01:40 AM 0
Share

There are always some hidden object exist in scene with null reference made by some plugins.

And you can delete that object by clicking it on Scene and press Delete.

avatar image basil3 · Aug 23, 2018 at 02:07 PM 0
Share

Hey,

The problem is the object is invisible in scene. So unfortunately I can’t click on it. I think I deleted the child that contained the mesh renderer.

Any other way of finding all objects that exist in scene? Other than searching hierarchy?

Ste

avatar image NoDumbQuestion basil3 · Aug 23, 2018 at 02:20 PM 1
Share

You can get all object in scene and look for null component. The only hidden object in scene I know of is _Dispacher with null script inside it like it was made of C++ object.

http://answers.unity.com/answers/1279524/view.html

avatar image basil3 NoDumbQuestion · Aug 23, 2018 at 06:01 PM 0
Share

Thanks for the help!

I've implemented the steps suggested and returned 20 null gameobjects, 19 of which are objects I have set to be inactive in the hierarchy and 1 of which is my 'invisible' gameobject called "$$anonymous$$Bfoundation".

Somehow the hideflag attribute had been altered to hide the object.

Anyway I wrote an editor script to make it unhide and then deleted it. Viola!

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 using UnityEditor.Scene$$anonymous$$anagement;
 using UnityEngine.Scene$$anonymous$$anagement;
 
 [InitializeOnLoad]
 public class DeleteObject : Editor {
 
     static DeleteObject() {
 
         List<GameObject> rootObjects = new List<GameObject>();
 
         // get root objects in scene
 
         Scene scene = Scene$$anonymous$$anager.GetActiveScene();
         scene.GetRootGameObjects( rootObjects );
 
         // iterate root objects and do something
 
         for (int i = 0; i < rootObjects.Count; ++i) {
 
             GameObject gameObject = rootObjects[i];
 
             if (gameObject != null) { 
 
                 Debug.Log ("Found the hidden passage");
 
 
                 if (gameObject.name == "$$anonymous$$BFoundation") {
 
                     gameObject.hideFlags = HideFlags.None;
                 }
             }
         }
     }
 }



1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by basil3 · Aug 23, 2018 at 06:04 PM

Here was the answer:

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[i];
 
             if (gameObject != null) { 
 
                 Debug.Log ("Found the hidden passage");
 
 
                 if (gameObject.name == "MBFoundation") {
 
                     gameObject.hideFlags = HideFlags.None;
                 }
             }
         }
     }
 }



Massive thanks to @NoDumbQuestion for the help on this one!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ClearRoseOfWar · Apr 04 at 02:41 AM 0
Share

@basil3 Thank you so much for leaving this here for everyone to find.. Much Love! <3 Helped me out huge!!

I got the name of each gameobject and found the one that was hidden, then deleted it by using the following if statement: Debug.Log (gameObject.name); if (gameObject.name == "Vine Bottom") { DestroyImmediate(gameObject); }

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

161 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Hierarchy objects deleted and 999+ errors when adding terrain 0 Answers

Game running different depending on what is selected in hierarchy. 0 Answers

Why won't my downloaded asset appear in the scene or hierarchy? 1 Answer

Dont destroy on load results in new scene with all deleted objects c# 1 Answer

Assets randomly deleted, how do I get them back? ,Prefabs randomly deleted after opening scene, how do I get them back? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges