mirror of https://github.com/godotengine/godot
Fix add_root_node() being no-op
This commit is contained in:
parent
29b3d9e9e5
commit
98871c3057
|
|
@ -44,8 +44,7 @@
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="node" type="Node" />
|
<param index="0" name="node" type="Node" />
|
||||||
<description>
|
<description>
|
||||||
Adds [param node] as a child of the root node in the editor context.
|
Makes [param node] root of the currently opened scene. Only works if the scene is empty. If the [param node] is a scene instance, an inheriting scene will be created.
|
||||||
[b]Warning:[/b] The implementation of this method is currently disabled.
|
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_editor_interface" qualifiers="const" deprecated="[EditorInterface] is a global singleton and can be accessed directly by its name.">
|
<method name="get_editor_interface" qualifiers="const" deprecated="[EditorInterface] is a global singleton and can be accessed directly by its name.">
|
||||||
|
|
@ -57,7 +56,7 @@
|
||||||
<method name="get_scene" qualifiers="const">
|
<method name="get_scene" qualifiers="const">
|
||||||
<return type="Node" />
|
<return type="Node" />
|
||||||
<description>
|
<description>
|
||||||
Returns the Editor's currently active scene.
|
Returns the edited (current) scene's root [Node]. Equivalent of [method EditorInterface.get_edited_scene_root].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,10 @@
|
||||||
|
|
||||||
#include "editor/editor_interface.h"
|
#include "editor/editor_interface.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
|
#include "editor/editor_undo_redo_manager.h"
|
||||||
|
#include "editor/gui/editor_scene_tabs.h"
|
||||||
#include "scene/main/node.h"
|
#include "scene/main/node.h"
|
||||||
|
#include "scene/resources/packed_scene.h"
|
||||||
|
|
||||||
void EditorScript::add_root_node(Node *p_node) {
|
void EditorScript::add_root_node(Node *p_node) {
|
||||||
if (!EditorNode::get_singleton()) {
|
if (!EditorNode::get_singleton()) {
|
||||||
|
|
@ -41,11 +44,24 @@ void EditorScript::add_root_node(Node *p_node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EditorNode::get_singleton()->get_edited_scene()) {
|
if (EditorNode::get_singleton()->get_edited_scene()) {
|
||||||
EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("There is an edited scene already."));
|
EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("The current scene already has a root node."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//editor->set_edited_scene(p_node);
|
const String &scene_path = p_node->get_scene_file_path();
|
||||||
|
if (!scene_path.is_empty()) {
|
||||||
|
Ref<PackedScene> scene = ResourceLoader::load(scene_path);
|
||||||
|
if (scene.is_valid()) {
|
||||||
|
memfree(scene->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE)); // Ensure node cache.
|
||||||
|
|
||||||
|
p_node->set_scene_inherited_state(scene->get_state());
|
||||||
|
p_node->set_scene_file_path(String());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorNode::get_singleton()->set_edited_scene(p_node);
|
||||||
|
EditorUndoRedoManager::get_singleton()->set_history_as_unsaved(EditorNode::get_editor_data().get_current_edited_scene_history_id());
|
||||||
|
EditorSceneTabs::get_singleton()->update_scene_tabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *EditorScript::get_scene() const {
|
Node *EditorScript::get_scene() const {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue