Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of custom Resources with class_name is saved using its path and breaks if the script is moved #90963

Closed
KoBeWi opened this issue Apr 20, 2024 · 7 comments

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Apr 20, 2024

Tested versions

4.3 dev 5 and probably earlier, idk if it's a regression

System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 31.0.15.4633) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

Issue description

When you have a custom resource with class_name and export an array of that resource, the array will be serialized as Array[Resource("res://path/to/script.gd")], completely ignoring class_name. When you move the script, the referenced path is not updated and the resource with array can't be loaded anymore.

If script has class_name, the array should use class name.
If it doesn't, it should use UID instead (once we have them in scripts).

Steps to reproduce

  1. Open the MRP
  2. Open Resources.tres
  3. It opens
  4. Move ContainedResource.gd to Folder
  5. Restart the project
  6. Resources.tres no longer opens

Minimal reproduction project (MRP)

bugpath.zip

@akien-mga
Copy link
Member

Might be related to recent typed array marshalling changes, cc @dalexeev.

@dalexeev
Copy link
Member

dalexeev commented Apr 21, 2024

However, you need to save the resource once so that the script path is saved as ExtResource.

Before save:

[gd_resource type="Resource" script_class="ResourceContainer" load_steps=3 format=3 uid="uid://bj4r1yoqqhakg"]

[ext_resource type="Script" path="res://ResourceContainer.gd" id="1_1u0yv"]
[ext_resource type="Resource" uid="uid://ogkvdrpc07li" path="res://Contained1.tres" id="1_pvmiw"]

[resource]
script = ExtResource("1_1u0yv")
resources = Array[Resource("res://ContainedResource.gd")]([ExtResource("1_pvmiw")])

After save:

[gd_resource type="Resource" script_class="ResourceContainer" load_steps=4 format=4 uid="uid://bj4r1yoqqhakg"]

[ext_resource type="Script" path="res://ResourceContainer.gd" id="1_1u0yv"]
[ext_resource type="Script" path="res://ContainedResource.gd" id="1_8b4xi"]
[ext_resource type="Resource" uid="uid://ogkvdrpc07li" path="res://Contained1.tres" id="1_pvmiw"]

[resource]
script = ExtResource("1_1u0yv")
resources = Array[ExtResource("1_8b4xi")]([ExtResource("1_pvmiw")])

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 21, 2024

I forgot to test on master, indeed the bug is fixed.

@KoBeWi KoBeWi closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2024
@moshujsg
Copy link

moshujsg commented Jul 9, 2024

Is there a workaround for this problem in the meantime?

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 9, 2024

The issue is resolved in 4.3 beta.

@moshujsg
Copy link

moshujsg commented Jul 9, 2024

I'm running 4.3 beta2 and still have this issue

@dalexeev
Copy link
Member

dalexeev commented Jul 9, 2024

@moshujsg See #90963 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants