1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-21 14:57:09 +00:00

Clear the previously set state when configuring for a new scene root node

Saving a subscene causes the main scene to be re-instantiated. And the resource
instance in the main scene will be reused when the main scene is re-instantiated.
So for resources with `resource_local_to_scene` enabled, resetting state may be
necessary (at least for `ViewportTexture`).

(cherry picked from commit 4795c3cdfa)
This commit is contained in:
Rindbee
2023-07-08 19:38:27 +08:00
committed by Yuri Sizov
parent d5a11e17b8
commit 00d5da2f09
4 changed files with 20 additions and 6 deletions

View File

@@ -88,12 +88,7 @@ void ViewportTexture::setup_local_to_scene() {
}
}
void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
if (path == p_path) {
return;
}
path = p_path;
void ViewportTexture::reset_local_to_scene() {
vp_changed = true;
if (vp) {
@@ -105,6 +100,16 @@ void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
proxy_ph = RS::get_singleton()->texture_2d_placeholder_create();
RS::get_singleton()->texture_proxy_update(proxy, proxy_ph);
}
}
void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
if (path == p_path) {
return;
}
path = p_path;
reset_local_to_scene();
if (get_local_scene() && !path.is_empty()) {
setup_local_to_scene();