This commit is contained in:
Spartan322
2025-02-21 23:27:43 -05:00
283 changed files with 80699 additions and 11854 deletions

View File

@@ -94,7 +94,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;
}
@@ -284,3 +284,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);
}