- Home /
Game view fails to work after wierd casting error.
Hello Everyone.
I was busy Creating an editor script when I got a seemingly unrelated error message:
"pptr cast failed when dereferencing Casting from DefaultAsset to Shader!".
Since this error message the game view is completely blanked out with a default blue color making it impossible to test the game.
I removed the script that I was working on when the error occurred but nothing changed.
I have a camera in the scene that is rendering to the default render texture. It's preview shows all the game objects as expected.
I have set the camera's background to white but the game view still stays the default blue.
The camera's culling mask is set to "Everything".
The camera's tag is "MainCamera".
I have restarted Unity and the computer multiple times.
This error seems to be a known issue with Unity but I cant find any reports of it affecting the editor. The error may just be a coincidence but that seems unlikely.
How can I fix the game view? Am I missing something obvious?
Any help would be greatly appreciated. :)
Thanks - Ross
Answer by Ross_B · Nov 22, 2013 at 12:11 PM
Well. That was silly.
Basically The script I was writing created a Camera in a GameObject with hideFlags.HideInHierachy enabled. When i closed the window it was supposed to delete the gameObject but the first time I closed it I used Destroy() instead of destroyImmediate().
My main camera had a depth of -1 which meant that the hidden camera took priority. The net result was a phantom camera that took priority over every camera below 0 depth. Since the near clipping plane of the phantom camera was too far (for my pseudo-2D game) It left me with a lovely blue Game view.