mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Store _custom_type_script meta as String
This commit is contained in:
parent
ad9abe841d
commit
38d0e82a35
5 changed files with 49 additions and 15 deletions
|
|
@ -39,6 +39,7 @@
|
|||
#include "editor/multi_node_edit.h"
|
||||
#include "editor/plugins/editor_context_menu_plugin.h"
|
||||
#include "editor/plugins/editor_plugin.h"
|
||||
#include "scene/property_utils.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
void EditorSelectionHistory::cleanup_history() {
|
||||
|
|
@ -536,15 +537,18 @@ Variant EditorData::instantiate_custom_type(const String &p_type, const String &
|
|||
if (get_custom_types()[p_inherits][i].name == p_type) {
|
||||
Ref<Script> script = get_custom_types()[p_inherits][i].script;
|
||||
|
||||
Variant ob = ClassDB::instantiate(p_inherits);
|
||||
ERR_FAIL_COND_V(!ob, Variant());
|
||||
// Store in a variant to initialize the refcount if needed.
|
||||
Variant v = ClassDB::instantiate(p_inherits);
|
||||
ERR_FAIL_COND_V(!v, Variant());
|
||||
Object *ob = v;
|
||||
|
||||
Node *n = Object::cast_to<Node>(ob);
|
||||
if (n) {
|
||||
n->set_name(p_type);
|
||||
}
|
||||
n->set_meta(SceneStringName(_custom_type_script), script);
|
||||
((Object *)ob)->set_script(script);
|
||||
return ob;
|
||||
PropertyUtils::assign_custom_type_script(ob, script);
|
||||
ob->set_script(script);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -988,12 +992,13 @@ Variant EditorData::script_class_instance(const String &p_class) {
|
|||
Ref<Script> script = script_class_load_script(p_class);
|
||||
if (script.is_valid()) {
|
||||
// Store in a variant to initialize the refcount if needed.
|
||||
Variant obj = ClassDB::instantiate(script->get_instance_base_type());
|
||||
if (obj) {
|
||||
Object::cast_to<Object>(obj)->set_meta(SceneStringName(_custom_type_script), script);
|
||||
obj.operator Object *()->set_script(script);
|
||||
Variant v = ClassDB::instantiate(script->get_instance_base_type());
|
||||
if (v) {
|
||||
Object *obj = v;
|
||||
PropertyUtils::assign_custom_type_script(obj, script);
|
||||
obj->set_script(script);
|
||||
}
|
||||
return obj;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return Variant();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue