Skip to content

Commit

Permalink
GH-532 Align Get Scene Node class on path change
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Jul 20, 2024
1 parent 674fb74 commit 43379ec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/script/nodes/scene/scene_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "common/property_utils.h"
#include "common/scene_utils.h"
#include "common/string_utils.h"
#include "script/script_server.h"

#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/node.hpp>
Expand Down Expand Up @@ -81,6 +82,19 @@ bool OScriptNodeSceneNode::_set(const StringName& p_name, const Variant& p_value
if (p_name.match("node_path"))
{
_node_path = p_value;

if (_initialized)
{
if (Node* node = _get_referenced_node())
{
Ref<Script> script = node->get_script();
if (script.is_valid() && !script->get_global_name().is_empty())
_class_name = script->get_global_name();
else
_class_name = node->get_class();
}
}

_notify_pins_changed();
return true;
}
Expand Down

0 comments on commit 43379ec

Please sign in to comment.