mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
-Make sure scenes properly update when switching tabs, even if sub-instances changed. Fixes #3201
This commit is contained in:
parent
e2be837520
commit
4248c84e20
@ -725,6 +725,7 @@ Error ResourceInteractiveLoaderBinary::poll(){
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!ResourceCache::has(res_path))
|
||||
path=res_path;
|
||||
}
|
||||
|
||||
|
@ -1570,7 +1570,9 @@ Error ResourceInteractiveLoaderXML::poll() {
|
||||
if (main) {
|
||||
f->close();
|
||||
resource=res;
|
||||
if (!ResourceCache::has(res_path)) {
|
||||
resource->set_path(res_path);
|
||||
}
|
||||
error=ERR_FILE_EOF;
|
||||
return error;
|
||||
|
||||
|
@ -1597,6 +1597,16 @@ Node *PackedScene::instance(bool p_gen_edit_state) const {
|
||||
return s;
|
||||
}
|
||||
|
||||
void PackedScene::replace_state(Ref<SceneState> p_by) {
|
||||
|
||||
state=p_by;
|
||||
state->set_path(get_path());
|
||||
#ifdef TOOLS_ENABLED
|
||||
state->set_last_modified_time(get_last_modified_time());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void PackedScene::recreate_state() {
|
||||
|
||||
state = Ref<SceneState>( memnew( SceneState ));
|
||||
|
@ -198,6 +198,7 @@ public:
|
||||
Node *instance(bool p_gen_edit_state=false) const;
|
||||
|
||||
void recreate_state();
|
||||
void replace_state(Ref<SceneState> p_by);
|
||||
|
||||
virtual void set_path(const String& p_path,bool p_take_over=false);
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
@ -302,6 +302,10 @@ Error ResourceInteractiveLoaderText::poll() {
|
||||
if (error) {
|
||||
if (error!=ERR_FILE_EOF) {
|
||||
_printerr();
|
||||
} else {
|
||||
if (!ResourceCache::has(res_path)) {
|
||||
resource->set_path(res_path);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
@ -403,6 +407,9 @@ Error ResourceInteractiveLoaderText::poll() {
|
||||
_printerr();
|
||||
} else {
|
||||
resource=packed_scene;
|
||||
if (!ResourceCache::has(res_path)) {
|
||||
packed_scene->set_path(res_path);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -499,8 +499,8 @@ void EditorData::remove_scene(int p_idx){
|
||||
|
||||
bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths) {
|
||||
|
||||
if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
|
||||
return false;
|
||||
// if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
|
||||
// return false;
|
||||
|
||||
Ref<SceneState> ss;
|
||||
|
||||
|
@ -3623,7 +3623,18 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
|
||||
add_io_error(txt);
|
||||
}
|
||||
|
||||
if (ResourceCache::has(lpath)) {
|
||||
//used from somewhere else? no problem! update state
|
||||
Ref<PackedScene> ps = Ref<PackedScene>( ResourceCache::get(lpath)->cast_to<PackedScene>() );
|
||||
if (ps.is_valid()) {
|
||||
ps->replace_state( sdata->get_state() );
|
||||
ps->set_last_modified_time( sdata->get_last_modified_time() );
|
||||
sdata=ps;
|
||||
}
|
||||
|
||||
} else {
|
||||
sdata->set_path(lpath,true); //take over path
|
||||
}
|
||||
|
||||
Node*new_scene=sdata->instance(true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user