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

Renaming custom resources breaks scenes that have exported Array[CustomResource] #92068

Closed
GustJc opened this issue May 18, 2024 · 5 comments
Closed

Comments

@GustJc
Copy link
Contributor

GustJc commented May 18, 2024

Tested versions

  • Reproducible in: 4-3.dev5, 4.2.2.stable

System information

Windows 10 - Vulkan (forward+) - dedicated

Issue description

Renaming a folder that have a custom resource may break scenes that have @export vars using Array[CustomResource]

The renaming works if the @export type is the CustomResource type itself.
But it seems the renaming does not take into account values inside Arrays

Steps to reproduce

Steps:

  • Create a folder "Data Folder"
  • Inside "Data Folder, create a CustomResource class from Resource
  • Create a data file from CustomResource.
  • Create a scene script with @export var data_array Array[CustomResource
  • From the inspector, add an element to data_array and assign the created data file there.
  • Rename the folder "Data Folder" to "Data"

Results: Crashes scene ('Error while parsing the file'). Can't re-open.
The resources inside the Array are not updated after renaming the folder. So the parser fails with FileNotFound.
Expected: Files path properly updated.

Here's the data that was not updated:

[node name="ManagerClass" type="Node" parent="."]
script = ExtResource("1_chnwi")
data = Array[Resource("res://Data Folder/data_resource.gd")]([ExtResource("2_dgo2u")])

Something similar also happens if you use sub-resources, creating the resource from the inspector.
But in 4.3-dev5. It won't break the scene.
And it'll only spits the error when you select the node that has that export variable.

  Attempt to open script 'res://Data Folder/data_resource.gd' resulted in error 'File not found'.
  Failed loading resource: res://Data Folder/data_resource.gd. Make sure resources have been imported by opening the project in the editor at least once.

You can revert it by changing the folder name back. Or by opening the scene file as a text and updating the paths manually.

Minimal reproduction project (MRP)

Minimal reproduction project:
bugs_rename_resource.zip

  • Rename the folder -> Breaks scene
@AThousandShips
Copy link
Member

AThousandShips commented May 18, 2024

Can you please try dev6

@dalexeev
Copy link
Member

Here's the data that was not updated:

[node name="ManagerClass" type="Node" parent="."]
script = ExtResource("1_chnwi")
data = Array[Resource("res://Data Folder/data_resource.gd")]([ExtResource("2_dgo2u")])

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")])

New scenes/resources (created or saved after the fix) update paths correctly. Old scenes/resources still do not handle such renaming, so they must be saved at least once in the new version of the engine.

Something similar also happens if you use sub-resources, creating the resource from the inspector.
But in 4.3-dev5. It won't break the scene.
And it'll only spits the error when you select the node that has that export variable.

I'm not sure about this. An input from editor contributors would be appreciated.

@GustJc
Copy link
Contributor Author

GustJc commented May 19, 2024

You need to save the resource once so that the script path is saved as ExtResource.

I was using 4.3.dev5 so it wasn't working, even after saving the files.

Can you please try dev6

You are totally right. It seems this is fixed on 4.3.dev6.
I think this can be closed.

@GustJc
Copy link
Contributor Author

GustJc commented May 19, 2024

Closing this, fixed in 4.3.dev6.


On a totally unrelated note.
On 4.3.dev6 now, I'm always getting an error message "A file or folder with this name already exists" while trying to renamed any folder. Even an empty one. But it does rename it, and everything works. Just the error box every time.
Is this already being tracked?

@GustJc GustJc closed this as completed May 19, 2024
@dalexeev
Copy link
Member

On 4.3.dev6 now, I'm always getting an error message "A file or folder with this name already exists" while trying to renamed any folder. [...]
Is this already being tracked?

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

3 participants