1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Refactor auto-instantiation of Object properties in editor

Auto-instantiation is used by the create dialog, but should also be
used by the editor inspector.

This refactors object properties auto-instantiation into a dedicated
method to be reused throughout editor (and possibly scripting).
This commit is contained in:
Andrii Doroshenko (Xrayez)
2020-10-22 22:02:57 +03:00
parent 28174d531b
commit 7a8b11ee14
6 changed files with 28 additions and 12 deletions

View File

@@ -446,17 +446,7 @@ Variant CreateDialog::instance_selected() {
} else {
obj = ClassDB::instantiate(selected->get_text(0));
}
// Check if any Object-type property should be instantiated.
List<PropertyInfo> pinfo;
((Object *)obj)->get_property_list(&pinfo);
for (const PropertyInfo &pi : pinfo) {
if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) {
Object *prop = ClassDB::instantiate(pi.class_name);
((Object *)obj)->set(pi.name, prop);
}
}
EditorNode::get_editor_data().instantiate_object_properties(obj);
return obj;
}