Hi folks, we’ve been plagued by this error when reloading a level. I understand it comes from a camera hanging on to a render texture when being destroyed, but I don’t which camera or render texture could be causing it, nor how to fix it. It also happens most often in builds, but only some builds.
There’s only one camera in the scene that has a rendertexture. There’s a prefab camera with a reference to a rendertexture asset, which is later instantiated. Before we reset the level, we manually clear the targetTexture field of the instantiated camera and destroy it.
Our reset code does a little cleanup, then calls yield LoadSceneAsync on the main scene of the level, then does yield Resources.UnloadUnusedAssets. The “Releasing render texture that is set as Camera.targetTexture!” error happens somewhere in the UnloadUnusedAssets.
Right before the UnloadUnusedAssets, I tried doing a FindAllObjectsOfType, and at this stage of the load there’s only our main camera in the new scene, and it has no render texture.
The fact that it happens only in some builds makes me think it’s a script execution order thing, but I’ve speculatively put some [DefaultExecutionOrder] tags in suspect places and not been able to make it consistent.
We’re on unity 2019.4.15
At this stage, I’m out of debugging ideas. Why is it inconsistent? Am I cleaning up the only rendertexture properly? What other debugging could I do? Any help greatly appreciated.