diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2015-12-14 07:39:17 +0100 |
---|---|---|
committer | Rémi Verschelde <remi@verschelde.fr> | 2015-12-14 07:39:17 +0100 |
commit | 55684dbea4dc29def533c28f47a0c70df3650c2b (patch) | |
tree | b6ff09d98737c8341e3ad4b350f329001ed9c38d /tools/editor | |
parent | 7f96f0603e16a970c7b0ea1fba936e56baf80d4a (diff) | |
parent | 2e8ed75d8dc1dc16399fc695a1fb130f312f4c5b (diff) |
Merge pull request #3065 from TheHX/pr-array-editor
Fix array editor NodePath being relative to editor
Diffstat (limited to 'tools/editor')
-rw-r--r-- | tools/editor/array_property_edit.cpp | 9 | ||||
-rw-r--r-- | tools/editor/array_property_edit.h | 2 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 18 |
3 files changed, 25 insertions, 4 deletions
diff --git a/tools/editor/array_property_edit.cpp b/tools/editor/array_property_edit.cpp index 9cd443270b..64a2762095 100644 --- a/tools/editor/array_property_edit.cpp +++ b/tools/editor/array_property_edit.cpp @@ -209,6 +209,15 @@ void ArrayPropertyEdit::edit(Object* p_obj,const StringName& p_prop,Variant::Typ } +Node *ArrayPropertyEdit::get_node() { + + Object *o = ObjectDB::get_instance(obj); + if (!o) + return NULL; + + return o->cast_to<Node>(); +} + void ArrayPropertyEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("_set_size"),&ArrayPropertyEdit::_set_size); diff --git a/tools/editor/array_property_edit.h b/tools/editor/array_property_edit.h index acfb8e68ed..948b2a71a3 100644 --- a/tools/editor/array_property_edit.h +++ b/tools/editor/array_property_edit.h @@ -30,6 +30,8 @@ public: void edit(Object* p_obj, const StringName& p_prop, Variant::Type p_deftype); + Node *get_node(); + ArrayPropertyEdit(); }; diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 9fb623022b..c44cfa3d6e 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -915,15 +915,25 @@ void CustomPropertyEditor::_color_changed(const Color& p_color) { void CustomPropertyEditor::_node_path_selected(NodePath p_path) { - if (owner && owner->is_type("Node")) { + if (owner) { + + Node *node=NULL; + + if (owner->is_type("Node")) + node = owner->cast_to<Node>(); + else if (owner->is_type("ArrayPropertyEdit")) + node = owner->cast_to<ArrayPropertyEdit>()->get_node(); + + if (!node) { + v=p_path; + emit_signal("variant_changed"); + return; + } - Node *node = owner->cast_to<Node>(); Node *tonode=node->get_node(p_path); if (tonode) { - p_path=node->get_path_to(tonode); } - } v=p_path; |