What is destroying my GameObject

I’ve searched through all my code and cannot find what is causing it. I am making no calls to destroy the object itself. About 2 seconds after I move it it disappears from the hierarchy and the game. Is there any way in the debugger to break anytime an object is destroyed so that I can get a look at the call stack?


I know this is a really old forum but after hours of pain of not being able to figure it out. I discovered that the trail renderer is the cause of this. Hopefully, none of you are having this problem after 5 years, but if you are, I can confirm this is the cause. This is also for people of the future.

I would simply do this:

  • In MonoDevelop or Visual Studio use “Find In Files” and search your project for “Destroy(”
  • Before each occurrence insert a Debug.Log() with a meaningful text and append the name of the object it’s going to destroy. Something like: Debug.Log("Player:OnTriggerEnter: " + other.name);
  • In addition you can add a Debug.Log() to your OnDestroy callback (also with a meaningful text)
  • Run your game and check your logs.

I found out, via reflection, that two classes have the autodestruct property: UnityEngine.TrailRenderer and UnityEngine.ParticleAnimator (which is obsolete).

Had the same issue due to having a singleton script duplicated on one of my objects.

I had this happen to me and it was a really silly cause.

Basically I had some faulty logic in my code that called the load scene function asynchronously twice. You couldn’t really tell what was happening because the second scene load pretty much happened in the same frame as the first scene load, but that second scene load caused Unity to destroy all the objects in the scene before loading them again.

In a case like this, searching your code for Destroy() calls won’t do anything, because you aren’t calling it, Unity is.

I might aswell share my case, it could be caused by a scene change or domain reload, i am making a multiplayer game and on connection my networking layer was spawning objects mid scene change which where destroyed when loading the new scene. I got the networking layer wait until the scene was loaded.

If Bunny83’s solution didn’t work then probably it’s not your object that’s being directly destroyed, but some of its parents. Try to do the same, but get the transform.root.name instead.