- Home /
Why would a Camera disappear from the Hierarchy on play?
My Main Camera is disappearing from the Hierarchy when I hit play. If I go to the Scene view, I can see my GameObjects moving around, but my Main Camera disappears when I hit play so I am unable to see the actual game.
Not sure how it happened. I was testing a function which froze Unity, had to End Task it and after I reopened my scene, everything appears fine but my Main Camera ceases to exist when I hit play.
You probably destroyed it by script. What happens if you add another?
Any chance you have objects that destroy something they collide with in your scene? $$anonymous$$aybe they're destroying the camera. Otherwise, I would create a new class that extends the Camera class, replace the script on your camera with it, and add an "OnDestroy" method inside your class, then breakpoint in that method (throw some nonsense code in it like int x=0; for the breakpoint.) in $$anonymous$$ono.
Then if you're lucky, you'll get a callstack that shows who's destroying it, but probably only if something called DestroyImmediate() on it. Otherwise, all destroys occur at the end of the frame, so even if you call Destroy() on the camera from some other code, it won't show in the callstack (at least that's how it used to be).
Answer by halken · Mar 12, 2017 at 03:18 PM
I had the exact same problem in the first tutorial for the 2D UFO project. Closing Unity and opening the project again fixed it.