Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

What is Recovery GameObject

Discussion in 'Editor & General Support' started by Hawk0077, Nov 13, 2020.

  1. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    780
    After upgrading unity from 2019 to 2020 I keep getting several Recovery GameObjects in heirarchy. I keep deleting them and unity keeps creating them. How do I get rid of this behaviour? Its annoying as hell.

    Thanks.
     
    KarlKarl2000 likes this.
  2. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    507
    I updated to 2020.1.14 and we're noticing them in our project too. Any idea what they are? I'm guessing that they're game objects that typically are hidden in the scene hierarchy when running to restore gameobject data back but they are visible in this version and are deleted on STOP. The other problem is that some of our team is seeing them linger even after Unity is stopped. Does anyone have a repro project to send to Unity? I tried to reproduce this in a new project and was unable to with a simple test project.
     
    Last edited: Nov 20, 2020
    Hawk0077 likes this.
  3. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    780
    Mine don't disappear. They just keep adding more everytime I play or restart the project. I have no idea why theyre there. Or how to get rid of them.
     
    KarlKarl2000 likes this.
  4. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,275
  5. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    507
    I appreciate the suggestion. The problem isn't that they can't be deleted, the problem is that they are getting created by Unity and shouldn't be present in the hierarchy at all. This is a bug but I can't seem to repro in a test project to send to Unity.
     
    Crossway, KarlKarl2000 and Hawk0077 like this.
  6. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    137
    Seeing the same after upgrading from 2020.1.11 to 2020.1.15. Anyone pinpointed what is causing this yet?
     
  7. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    137
    Actually, I just found that this happens when you have a missing prefab in the scene. After I deleted it, the recovery gameobject stopped getting created.
     
  8. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    780
    Is there a specific way to find the missing game object or is it just the redish color?
     
  9. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,275
    Here you go.. this script will detect missing components and missing prefabs in a hierarchy (note this is an editor-only script).

    Add to any hierarchy's root, there's a checkbox "search" in the Inspector - click any time to search again, it will uncheck itself when complete. It will output results via Debug.Log (or just modify to suit your needs). Alternatively you can just call .Search() procedurally and keep the component disabled to skip the Update call.. or add a custom inspector with a button that calls Search and remove the Update function entirely.

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5. [ExecuteAlways]
    6. public class NullComponentAndMissingPrefabSearch : MonoBehaviour
    7. {
    8.   [Tooltip("click to log all missing/null components and prefabs in this hierarchy")]
    9.   public bool search = false;
    10.  
    11.   private List<string> results = new List<string>();
    12.   private void AppendComponentResult(string childPath, int index)
    13.   {
    14.     results.Add("Missing Component " + index + " of " + childPath);
    15.   }
    16.   private void AppendTransformResult(string childPath, string name)
    17.   {
    18.     results.Add("Missing Prefab for \"" + name + "\" of " + childPath);
    19.   }
    20.   public void Search()
    21.   {
    22.     results.Clear();
    23.     Traverse(transform);
    24.     Debug.Log("> Total Results: " + results.Count);
    25.     foreach (string result in results) Debug.Log("> " + result);
    26.   }
    27.   private void Update()
    28.   {
    29.     if (search)
    30.     {
    31.       Search();
    32.       search = false;
    33.     }
    34.   }
    35.  
    36.   private void Traverse(Transform transform, string path = "")
    37.   {
    38.     string thisPath = path + "/" + transform.name;
    39.     Component[] components = transform.GetComponents<Component>();
    40.     for (int i = 0; i < components.Length; i++)
    41.     {
    42.       if (components[i] == null) AppendComponentResult(thisPath, i);
    43.     }
    44.     for (int c = 0; c < transform.childCount; c++)
    45.     {
    46.       Transform t = transform.GetChild(c);
    47.       PrefabAssetType pt = PrefabUtility.GetPrefabAssetType(t.gameObject);
    48.       if (pt == PrefabAssetType.MissingAsset)
    49.       {
    50.         AppendTransformResult(path + "/" + transform.name, t.name);
    51.       } else
    52.       {
    53.         Traverse(t, thisPath);
    54.       }
    55.     }
    56.   }
    57. }
    58. #endif
     
    cdr9042, ge01f, sankatana and 3 others like this.
  10. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    287
    I'm having this issue and I can't delete the objects as they just come back. I might try your script @polemical if I need to work with that scene. Thanks/
     
  11. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,275
    Sure - I cleaned it up a bit, just drop this into an Editor folder and any time you can just click "Tools->Log Missing Prefabs And Components" - much easier than using a component.

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5. using UnityEditor;
    6.  
    7. public class NullComponentAndMissingPrefabSearchTool
    8. {
    9.   [MenuItem("Tools/Log Missing Prefabs And Components")]
    10.   public static void Search()
    11.   {
    12.     results.Clear();
    13.     GameObject[] gos = SceneManager.GetActiveScene().GetRootGameObjects();
    14.     foreach (GameObject go in gos) Traverse(go.transform);
    15.     Debug.Log("> Total Results: " + results.Count);
    16.     foreach (string result in results) Debug.Log("> " + result);
    17.   }
    18.  
    19.   private static List<string> results = new List<string>();
    20.   private static void AppendComponentResult(string childPath, int index)
    21.   {
    22.     results.Add("Missing Component " + index + " of " + childPath);
    23.   }
    24.   private static void AppendTransformResult(string childPath, string name)
    25.   {
    26.     results.Add("Missing Prefab for \"" + name + "\" of " + childPath);
    27.   }
    28.   private static void Traverse(Transform transform, string path = "")
    29.   {
    30.     string thisPath = path + "/" + transform.name;
    31.     Component[] components = transform.GetComponents<Component>();
    32.     for (int i = 0; i < components.Length; i++)
    33.     {
    34.       if (components[i] == null) AppendComponentResult(thisPath, i);
    35.     }
    36.     for (int c = 0; c < transform.childCount; c++)
    37.     {
    38.       Transform t = transform.GetChild(c);
    39.       PrefabAssetType pt = PrefabUtility.GetPrefabAssetType(t.gameObject);
    40.       if (pt == PrefabAssetType.MissingAsset)
    41.       {
    42.         AppendTransformResult(path + "/" + transform.name, t.name);
    43.       } else
    44.       {
    45.         Traverse(t, thisPath);
    46.       }
    47.     }
    48.   }
    49. }
    50. #endif
     
    Ylex, Crossway, Pandazole and 14 others like this.
  12. JohnEvelyn

    JohnEvelyn

    Joined:
    Oct 28, 2016
    Posts:
    9
    Just wanted to drop in and say - thanks for sharing this! I had a ton of junk dummy prefabs generating with each run of my scene in editor. It only started since I updated to 2020. This script made tracking down the exact location of the problem GOs totally painless.

    Cheers
     
    adamgolden likes this.
  13. EL-soNK

    EL-soNK

    Joined:
    Jul 13, 2015
    Posts:
    24
    The "NullComponentAndMissingPrefabSearchTool" is really super-helpful. Thank you very much @polemical
     
    adamgolden likes this.
  14. lukem123

    lukem123

    Joined:
    Oct 30, 2019
    Posts:
    5
    Thank you so much @polemical this finally helped me catch the issue, it was so annoying!
     
    adamgolden likes this.
  15. Master_Bronze_Elite

    Master_Bronze_Elite

    Joined:
    Jun 1, 2021
    Posts:
    1
    Thanks a lot @polemical. Your script worked like a charm. Good luck to you on any future game dev. endeavors
     
    adamgolden likes this.
  16. ishangill

    ishangill

    Joined:
    Nov 28, 2017
    Posts:
    22
    Hello I am gill.

    Today I faced a very weird problem when I opened my project . I see all my child gameobject in my (city 1 scene) are merged with other game objects and position , rotation is changed and all the child objects are detached from the parent game object and some are deleted . I don't know how this happens.
    And this error is shown in the console
    ( parser failure at line 134041: expected closing )
    But it was my luck that I had saved the copy of the same scene with another name.
    So pls help me to solve this problem and I don't know about this error
    Pls help me .
     
  17. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    29,558
    First, please don't reply to old unrelated posts with new posts a year later. It's against forum rules.

    Second, it sounds like you have opened it with an earlier version of Unity.

    Either way, I'm sorry you've had this issue. Please consider using proper industrial-grade source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    Here's how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally setting Unity up (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards

    Beyond that, here is how to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/
     
  18. SolarianZ

    SolarianZ

    Joined:
    Jun 13, 2017
    Posts:
    119
  19. Pandazole

    Pandazole

    Joined:
    Sep 23, 2019
    Posts:
    9
    Thanks a bunch! Was looking for something similar a long time ago.

    Regards.
     
    adamgolden likes this.
  20. vignesh211

    vignesh211

    Joined:
    Feb 8, 2019
    Posts:
    13
    You can type "Missing" in the hierarchy and it will display the game objects that are missing the prefab and will be red in color.
    Removing them resolved the issue for me
     
  21. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    517
    I feel dumb for not thinking about this .... thanks for reminding me about the Search bar..
     
  22. asteroidpilot

    asteroidpilot

    Joined:
    Nov 28, 2016
    Posts:
    3
    Stuck at same Unity crash bug. Thanks for solution!
     
unityunity