mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #43015 from Xrayez/refactor-auto-instaprop
Refactor auto-instantiation of `Object` properties in editor
This commit is contained in:
commit
0154ce2c8d
6 changed files with 28 additions and 12 deletions
|
@ -503,17 +503,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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue