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

@@ -1632,7 +1632,8 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
// Some properties may have an instantiated Object as default value,
// (like Path2D's `curve` used to have), but that's not a good practice.
// Instead, those properties should use PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT
// to be auto-instantiated when created in the editor.
// to be auto-instantiated when created in the editor with the following method:
// EditorNode::get_editor_data().instantiate_object_properties(obj);
if (var.get_type() == Variant::OBJECT) {
Object *obj = var.get_validated_object();
if (obj) {