Fix array editor NodePath being relative to editor
This commit is contained in:
parent
451b1d9144
commit
2e8ed75d8d
|
@ -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);
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
|
||||
void edit(Object* p_obj, const StringName& p_prop, Variant::Type p_deftype);
|
||||
|
||||
Node *get_node();
|
||||
|
||||
ArrayPropertyEdit();
|
||||
};
|
||||
|
||||
|
|
|
@ -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 = owner->cast_to<Node>();
|
||||
Node *tonode=node->get_node(p_path);
|
||||
if (tonode) {
|
||||
Node *node=NULL;
|
||||
|
||||
p_path=node->get_path_to(tonode);
|
||||
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 *tonode=node->get_node(p_path);
|
||||
if (tonode) {
|
||||
p_path=node->get_path_to(tonode);
|
||||
}
|
||||
}
|
||||
|
||||
v=p_path;
|
||||
|
|
Loading…
Reference in New Issue