Render Camera Becomes Null After Loading

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pixelemm
Posts: 5
Joined: Fri Jul 19, 2024 2:48 am

Render Camera Becomes Null After Loading

Post by pixelemm »

Hi,

I'm having an issue where after I load a save slot, my canvas' Render Camera becomes null.
The render camera is correct when starting up the game. I hope there is a way to solve this.

I've attached some screenshots to illustrate the problem.
Before start
Before start
01.png (466.7 KiB) Viewed 688 times
During Start
During Start
02.png (859.78 KiB) Viewed 688 times
After loading
After loading
03.png (765.83 KiB) Viewed 688 times
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Render Camera Becomes Null After Loading

Post by Tony Li »

Hi,

This is probably the same issue as described in How To: Manage Player Controls and Scene Changes. Please see that link and let me know if you have any questions. The issue is that the Dialogue Manager survives the scene change, but the render camera doesn't. (The render camera probably shouldn't survive scene changes.) In this case, you'll want to write a very small script or something to reconnect the newly-loaded scene's render camera.
pixelemm
Posts: 5
Joined: Fri Jul 19, 2024 2:48 am

Re: Render Camera Becomes Null After Loading

Post by pixelemm »

Hi,

I got it to work by writing a small script that uses a coroutine to constantly check if the desired camera exists and assign it to the dialogue system!

Thanks for the reply
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Render Camera Becomes Null After Loading

Post by Tony Li »

Hi,

Sounds good. But you could probably optimize it by checking once in a Start() method, and putting that script on a GameObject (e.g., empty GameObject) in each scene. That way you don't have to constantly check.
Post Reply