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

Custom resource data imported via EditorImportPlugin not read in game #97788

Closed
paskausks opened this issue Oct 3, 2024 · 3 comments · Fixed by #97817
Closed

Custom resource data imported via EditorImportPlugin not read in game #97788

paskausks opened this issue Oct 3, 2024 · 3 comments · Fixed by #97817

Comments

@paskausks
Copy link

paskausks commented Oct 3, 2024

Tested versions

  • Reproducible in 4.4dev2 and 4.4dev3
  • Not reproducible in 4.3stable and 4.4dev1

System information

Godot v4.4.dev3 - Ubuntu 22.04.5 LTS 22.04 on X11 - X11 display driver, Single-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (nvidia; 535.183.01) - AMD Ryzen 5 3600 6-Core Processor (12 threads)

Issue description

It seems like there might be a regression with either custom resources or EditorImportPlugin.

In versions previous to 4.4dev2 I used a EditorImportPlugin to load an array of Task custom resources as a TaskList resource from a CSV file. In 4.4dev2 and 4.4dev3 loading the CSV from game code seems to return an empty array instead. No errors are produced. Interestingly enough, in affected versions the imported data can be viewed in the editor. Also loading the resource from a @tool script seems to work.

image

Instead of an array of custom resources, I also tried to load an array of String, which made no difference.

Steps to reproduce

  • Create resource to hold an array of data (another custom resource in my case).
  • Create an EditorImportPlugin which reads a CSV and saves it as the aforementioned container resource
  • Create custom CSV data and let Godot import that via the EditorImportPlugin
  • Observe that the resource can be explored in the editor, meaning that it has been successfully imported
  • Add code to load or preload the CSV data during runtime
  • Observe that the loaded data is an empty array

Minimal reproduction project (MRP)

csvimport.zip

@donn-xx
Copy link

donn-xx commented Oct 4, 2024

I compiled (b72d8a3) and tried the MRP. Indeed, when running the project, there is no attempt at importing the csv file.

I added a print in the _import func and it does not reach that point when running (F5). It's fine in-editor.

func _import(source_file: String, save_path: String, options: Dictionary, platform_variants: Array[String], gen_files: Array[String]) -> int:
	print("_import runs")

ETA: Just tried it again on f4af820 and it's the same.

@eviltrout
Copy link
Contributor

eviltrout commented Oct 4, 2024

I tried out the MRP and the _import is being called properly, and the resource is being created correctly (you can confirm by looking in .godot/import.

The issue seems to be related to typing when loading the resource.

This example has a parent class TaskList which has exported an array of Task objects, declared like this:

@export var data: Array[Task] = []

If you remove the Task type for the array, say @export var data: Array = [] it correctly prints the values at runtime, even using the Task class's _to_string

No re-import is required. This implies to me that perhaps the Task class/type is not found or loaded when Godot is loading the resource, so it leaves the array empty.

One strange thing is I tried putting another @export var t: Task as a test into the resource and it worked fine, so this issue seems to be specific to loading a resource with a typed array of other resources.

@akien-mga
Copy link
Member

akien-mga commented Oct 4, 2024

I bisected the regression to #96780, CC @bruvzg.
Took a while as this was literally the last PR merged before building 4.4.dev2 :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Release Blocker
Development

Successfully merging a pull request may close this issue.

5 participants