You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Store _custom_type_script meta as String
This commit is contained in:
@@ -92,7 +92,7 @@ Variant PropertyUtils::get_property_default_value(const Object *p_object, const
|
||||
// Handle special case "script" property, where the default value is either null or the custom type script.
|
||||
// Do this only if there's no states stack cache to trace for default values.
|
||||
if (!p_states_stack_cache && p_property == CoreStringName(script) && p_object->has_meta(SceneStringName(_custom_type_script))) {
|
||||
Ref<Script> ct_scr = p_object->get_meta(SceneStringName(_custom_type_script));
|
||||
Ref<Script> ct_scr = get_custom_type_script(p_object);
|
||||
if (r_is_valid) {
|
||||
*r_is_valid = true;
|
||||
}
|
||||
@@ -282,3 +282,29 @@ Vector<SceneState::PackState> PropertyUtils::get_node_states_stack(const Node *p
|
||||
}
|
||||
return states_stack_ret;
|
||||
}
|
||||
|
||||
void PropertyUtils::assign_custom_type_script(Object *p_object, const Ref<Script> &p_script) {
|
||||
ERR_FAIL_NULL(p_object);
|
||||
ERR_FAIL_COND(p_script.is_null());
|
||||
|
||||
const String &path = p_script->get_path();
|
||||
ERR_FAIL_COND(!path.is_resource_file());
|
||||
|
||||
ResourceUID::ID script_uid = ResourceLoader::get_resource_uid(path);
|
||||
if (script_uid != ResourceUID::INVALID_ID) {
|
||||
p_object->set_meta(SceneStringName(_custom_type_script), ResourceUID::get_singleton()->id_to_text(script_uid));
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Script> PropertyUtils::get_custom_type_script(const Object *p_object) {
|
||||
Variant custom_script = p_object->get_meta(SceneStringName(_custom_type_script));
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
if (custom_script.get_type() == Variant::OBJECT) {
|
||||
// Convert old script meta.
|
||||
Ref<Script> script_object(custom_script);
|
||||
assign_custom_type_script(const_cast<Object *>(p_object), script_object);
|
||||
return script_object;
|
||||
}
|
||||
#endif
|
||||
return ResourceLoader::load(custom_script);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user