You've already forked godot
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user