-
-
Notifications
You must be signed in to change notification settings - Fork 108
Description
Issue description
When loading a PackedScene
that has a PhantomCamera2D
in it's scene tree that has a higher priority than the current pcam, the PhantomCameraHost
will set it as the active pcam before the scene has finished instantiating (or before the pcam object itself has even finished loading all of it's properties). This seems like unintended behavior as you probably don't want to switch to a camera before it is added to the scene tree.
I was just trying to log some information about which cameras were being activated when I encountered this but I imagine it will cause problems if a scene is loaded in the background during gameplay before it is needed to be added to the scene.
It seems that this is caused because PackedScene.instantiate()
creates the PhantomCamera object, iterates over its properties and sets the values based on the contents of the scene file. When it reaches the priority, it calls the setter function, which finds the PhantomCameraManager
singleton and emits its priority_changed
signal that is then responded to by the pcam host, which receives a reference to the camera before it has been fully loaded from the file.
Steps to reproduce
I have included a MRP with some logging set up that illustrates the issue.
You can see that new_cam.name
is empty when the pcam_became_active
signal is received.