1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

GDScript: Enable exporting nodes to the inspector

Also fix an small issue in the property editor for NodePath trying to
use the meta property when not needed.
This commit is contained in:
George Marques
2022-06-27 18:41:07 -03:00
parent c41e4b10c3
commit 9490146a16
2 changed files with 11 additions and 3 deletions

View File

@@ -3026,13 +3026,17 @@ String EditorPropertyNodePath::_get_meta_pointer_property() const {
Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool &r_valid) const { Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool &r_valid) const {
if (p_prop == get_edited_property()) { if (p_prop == get_edited_property()) {
r_valid = true; r_valid = true;
return const_cast<EditorPropertyNodePath *>(this)->get_edited_object()->get(_get_meta_pointer_property(), &r_valid); return const_cast<EditorPropertyNodePath *>(this)->get_edited_object()->get(pointer_mode ? StringName(_get_meta_pointer_property()) : get_edited_property(), &r_valid);
} }
return Variant(); return Variant();
} }
StringName EditorPropertyNodePath::_get_revert_property() const { StringName EditorPropertyNodePath::_get_revert_property() const {
if (pointer_mode) {
return _get_meta_pointer_property(); return _get_meta_pointer_property();
} else {
return get_edited_property();
}
} }
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {

View File

@@ -3605,8 +3605,12 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
variable->export_info.type = Variant::OBJECT; variable->export_info.type = Variant::OBJECT;
variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE; variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE;
variable->export_info.hint_string = export_type.native_type; variable->export_info.hint_string = export_type.native_type;
} else if (ClassDB::is_parent_class(export_type.native_type, SNAME("Node"))) {
variable->export_info.type = Variant::OBJECT;
variable->export_info.hint = PROPERTY_HINT_NODE_TYPE;
variable->export_info.hint_string = export_type.native_type;
} else { } else {
push_error(R"(Export type can only be built-in, a resource, or an enum.)", variable); push_error(R"(Export type can only be built-in, a resource, a node, or an enum.)", variable);
return false; return false;
} }
break; break;