Skip to content

Commit

Permalink
GH-510 Pass class type initialization to New Object nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Jul 13, 2024
1 parent f6dd912 commit 30b4a57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/editor/graph/actions/default_action_registrar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,14 @@ void OrchestratorDefaultGraphActionRegistrar::_register_script_nodes(const Orche
_register_node<OScriptNodeInputAction>(p_context, "Input/input_action");

// Memory
_register_node<OScriptNodeNew>(p_context, "Memory/new_object");
_register_node<OScriptNodeFree>(p_context, "Memory/free_object");
{
Dictionary new_object;
if (!p_context.filter->target_classes.is_empty())
new_object["class_name"] = p_context.filter->target_classes[0];
_register_node<OScriptNodeNew>(p_context, "Memory/new_object", new_object);

_register_node<OScriptNodeFree>(p_context, "Memory/free_object");
}

// Resource
_register_node<OScriptNodePreload>(p_context, "Resource/preload_resource");
Expand Down
4 changes: 4 additions & 0 deletions src/script/nodes/memory/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ OScriptNodeInstance* OScriptNodeNew::instantiate()
void OScriptNodeNew::initialize(const OScriptNodeInitContext& p_context)
{
_class_name = "Object";

if (p_context.user_data && p_context.user_data.value().has("class_name"))
_class_name = p_context.user_data.value()["class_name"];

super::initialize(p_context);
}

Expand Down

0 comments on commit 30b4a57

Please sign in to comment.