diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 621a94ab1a0..a03ddd09837 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -108,7 +108,7 @@ void ScriptDebuggerRemote::_put_variable(const String &p_name, const Variant &p_ } int len = 0; - Error err = encode_variant(var, NULL, len); + Error err = encode_variant(var, NULL, len, true); if (err != OK) ERR_PRINT("Failed to encode variant"); diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp index a32a71262f9..245c9273ff8 100644 --- a/editor/array_property_edit.cpp +++ b/editor/array_property_edit.cpp @@ -30,6 +30,7 @@ #include "array_property_edit.h" +#include "core/io/marshalls.h" #include "editor_node.h" #define ITEMS_PER_PAGE 100 @@ -202,6 +203,11 @@ bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { int idx = pn.get_slicec('/', 1).to_int(); bool valid; r_ret = arr.get(idx, &valid); + + if (r_ret.get_type() == Variant::OBJECT && Object::cast_to(r_ret)) { + r_ret = Object::cast_to(r_ret)->get_object_id(); + } + return valid; } } @@ -232,6 +238,11 @@ void ArrayPropertyEdit::_get_property_list(List *p_list) const { p_list->push_back(PropertyInfo(Variant::INT, "indices/" + itos(i + offset) + "_type", PROPERTY_HINT_ENUM, vtypes)); } + if (v.get_type() == Variant::OBJECT && Object::cast_to(v)) { + p_list->push_back(PropertyInfo(Variant::INT, "indices/" + itos(i + offset), PROPERTY_HINT_OBJECT_ID, "Object")); + continue; + } + if (is_typed || v.get_type() != Variant::NIL) { PropertyInfo pi(v.get_type(), "indices/" + itos(i + offset)); if (subtype != Variant::NIL) { diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 24360813a28..431f608f46e 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -29,9 +29,9 @@ /*************************************************************************/ #include "editor_properties_array_dict.h" +#include "core/io/marshalls.h" #include "editor/editor_scale.h" #include "editor_properties.h" - bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) { String pn = p_name; @@ -54,6 +54,10 @@ bool EditorPropertyArrayObject::_get(const StringName &p_name, Variant &r_ret) c int idx = pn.get_slicec('/', 1).to_int(); bool valid; r_ret = array.get(idx, &valid); + if (r_ret.get_type() == Variant::OBJECT && Object::cast_to(r_ret)) { + r_ret = Object::cast_to(r_ret)->get_object_id(); + } + return valid; } @@ -120,6 +124,10 @@ bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_r int idx = pn.get_slicec('/', 1).to_int(); Variant key = dict.get_key_at_index(idx); r_ret = dict[key]; + if (r_ret.get_type() == Variant::OBJECT && Object::cast_to(r_ret)) { + r_ret = Object::cast_to(r_ret)->get_object_id(); + } + return true; } @@ -198,6 +206,10 @@ void EditorPropertyArray::_change_type_menu(int p_index) { update_property(); } +void EditorPropertyArray::_object_id_selected(const String &p_property, ObjectID p_id) { + emit_signal("object_id_selected", p_property, p_id); +} + void EditorPropertyArray::update_property() { Variant array = get_edited_object()->get(get_edited_property()); @@ -431,9 +443,19 @@ void EditorPropertyArray::update_property() { } break; case Variant::OBJECT: { - EditorPropertyResource *editor = memnew(EditorPropertyResource); - editor->setup("Resource"); - prop = editor; + + if (Object::cast_to(value)) { + + EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID); + editor->setup("Object"); + prop = editor; + + } else { + + EditorPropertyResource *editor = memnew(EditorPropertyResource); + editor->setup("Resource"); + prop = editor; + } } break; case Variant::DICTIONARY: { @@ -497,6 +519,7 @@ void EditorPropertyArray::update_property() { prop->set_label(itos(i + offset)); prop->set_selectable(false); prop->connect("property_changed", this, "_property_changed"); + prop->connect("object_id_selected", this, "_object_id_selected"); if (array.get_type() == Variant::ARRAY) { HBoxContainer *hb = memnew(HBoxContainer); vbox->add_child(hb); @@ -578,6 +601,7 @@ void EditorPropertyArray::_bind_methods() { ClassDB::bind_method("_property_changed", &EditorPropertyArray::_property_changed, DEFVAL(false)); ClassDB::bind_method("_change_type", &EditorPropertyArray::_change_type); ClassDB::bind_method("_change_type_menu", &EditorPropertyArray::_change_type_menu); + ClassDB::bind_method("_object_id_selected", &EditorPropertyArray::_object_id_selected); } EditorPropertyArray::EditorPropertyArray() { @@ -893,9 +917,19 @@ void EditorPropertyDictionary::update_property() { } break; case Variant::OBJECT: { - EditorPropertyResource *editor = memnew(EditorPropertyResource); - editor->setup("Resource"); - prop = editor; + + if (Object::cast_to(value)) { + + EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID); + editor->setup("Object"); + prop = editor; + + } else { + + EditorPropertyResource *editor = memnew(EditorPropertyResource); + editor->setup("Resource"); + prop = editor; + } } break; case Variant::DICTIONARY: { @@ -986,6 +1020,7 @@ void EditorPropertyDictionary::update_property() { prop->set_selectable(false); prop->connect("property_changed", this, "_property_changed"); + prop->connect("object_id_selected", this, "_object_id_selected"); HBoxContainer *hb = memnew(HBoxContainer); if (add_vbox) { @@ -1022,6 +1057,10 @@ void EditorPropertyDictionary::update_property() { #endif } +void EditorPropertyDictionary::_object_id_selected(const String &p_property, ObjectID p_id) { + emit_signal("object_id_selected", p_property, p_id); +} + void EditorPropertyDictionary::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { @@ -1055,6 +1094,7 @@ void EditorPropertyDictionary::_bind_methods() { ClassDB::bind_method("_change_type", &EditorPropertyDictionary::_change_type); ClassDB::bind_method("_change_type_menu", &EditorPropertyDictionary::_change_type_menu); ClassDB::bind_method("_add_key_value", &EditorPropertyDictionary::_add_key_value); + ClassDB::bind_method("_object_id_selected", &EditorPropertyDictionary::_object_id_selected); } EditorPropertyDictionary::EditorPropertyDictionary() { diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index d2bd849f301..d5eecd91063 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -101,6 +101,8 @@ class EditorPropertyArray : public EditorProperty { void _change_type(Object *p_button, int p_index); void _change_type_menu(int p_index); + void _object_id_selected(const String &p_property, ObjectID p_id); + protected: static void _bind_methods(); void _notification(int p_what); @@ -134,6 +136,7 @@ class EditorPropertyDictionary : public EditorProperty { void _change_type_menu(int p_index); void _add_key_value(); + void _object_id_selected(const String &p_property, ObjectID p_id); protected: static void _bind_methods(); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index faa561ad548..559ab32505d 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -602,6 +602,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String n = p_data[ofs + i * 2 + 0]; Variant v = p_data[ofs + i * 2 + 1]; + PropertyHint h = PROPERTY_HINT_NONE; String hs = String();