Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions weaver-editor/jsb_editor_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ StringName GodotJSEditorHelper::_get_exposed_node_class_name(const StringName& c
return jsb::internal::NamingUtil::get_class_name(exposed_class_name);
}

Dictionary GodotJSEditorHelper::_build_node_type_descriptor(jsb::JSEnvironment& p_env, Node* p_node, const String& p_scene_resource_path)
Dictionary GodotJSEditorHelper::_build_node_type_descriptor(jsb::JSEnvironment& p_env, Node* p_node, Dictionary& r_unique_name_nodes, const String& p_scene_resource_path)
{
Dictionary descriptor;
Dictionary children;
Expand All @@ -119,7 +119,7 @@ Dictionary GodotJSEditorHelper::_build_node_type_descriptor(jsb::JSEnvironment&
for (int i = 0; i < child_count; i++)
{
Node* child = p_node->get_child(i, true);
children[child->get_name()] = _build_node_type_descriptor(p_env, child);
children[child->get_name()] = _build_node_type_descriptor(p_env, child, r_unique_name_nodes);
}

ScriptInstance* script_instance = p_node->get_script_instance();
Expand Down Expand Up @@ -253,6 +253,10 @@ Dictionary GodotJSEditorHelper::_build_node_type_descriptor(jsb::JSEnvironment&
}
}

if (p_node->is_unique_name_in_owner())
{
r_unique_name_nodes["%" + p_node->get_name()] = descriptor;
}
return descriptor;
}

Expand Down Expand Up @@ -330,7 +334,8 @@ Dictionary GodotJSEditorHelper::get_resource_type_descriptor(const String& p_pat
jsb::JSEnvironment env(instantiated_scene->get_scene_file_path(), true);

Array generic_arguments;
generic_arguments.push_back(_build_node_type_descriptor(env, instantiated_scene, p_path));
Dictionary unique_name_nodes;
generic_arguments.push_back(_build_node_type_descriptor(env, instantiated_scene, unique_name_nodes, p_path));

descriptor[jsb_string_name(type)] = (int32_t) DescriptorType::Godot;
descriptor[jsb_string_name(name)] = "PackedScene";
Expand Down Expand Up @@ -407,16 +412,18 @@ Dictionary GodotJSEditorHelper::get_scene_nodes(const String& p_path)
v8::HandleScope handle_scope(isolate);

Dictionary nodes;
Dictionary unique_name_nodes;
int child_count = instantiated_scene->get_child_count(true);

for (int i = 0; i < child_count; i++)
{
Node* child = instantiated_scene->get_child(i, true);
nodes[child->get_name()] = _build_node_type_descriptor(env, child);
nodes[child->get_name()] = _build_node_type_descriptor(env, child, unique_name_nodes);
}

instantiated_scene->queue_free();

nodes.merge(unique_name_nodes);
return nodes;
}

Expand Down
2 changes: 1 addition & 1 deletion weaver-editor/jsb_editor_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GodotJSEditorHelper : public Object

static bool _request_codegen(jsb::JSEnvironment& p_env, GodotJSScript* p_script, const Dictionary& p_request, Dictionary& p_result);
static StringName _get_exposed_node_class_name(const StringName& class_name);
static Dictionary _build_node_type_descriptor(jsb::JSEnvironment& p_env, Node* p_node, const String& p_scene_resource_path = String());
static Dictionary _build_node_type_descriptor(jsb::JSEnvironment& p_env, Node* p_node, Dictionary& r_unique_name_nodes, const String& p_scene_resource_path = String());
static void _log_load_error(const String &p_file, const String &p_type, Error p_error);

protected:
Expand Down
Loading