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

Preloaded resources in .gd scripts don't get exported as dependencies of those scripts #18641

Closed
jahd2602 opened this issue May 5, 2018 · 4 comments

Comments

@jahd2602
Copy link
Contributor

jahd2602 commented May 5, 2018

Godot version:
3.0.2 stable

OS/device including version:
MacBook Air (13-inch, Early 2014) (1,4 GHz Intel Core i5)
MacOS High Sierra 10.13.3

Issue description:
When selecting Project > Export > Export selected resources (and dependencies), .gd scripts selected won't include as dependencies the preloaded resources included in the script.

Steps to reproduce:

  1. Create scriptParent.gd and preload scriptChild.gd
  2. Set first node script to scriptParent.gd
  3. Enable Project > Export > Export selected resources (and dependencies)
  4. Select the scene to be exported
  5. Play on device

What it should do
Load the scene correctly because the scene references scriptParent.gd, and this scripts is preloading scriptChild.gd so it should be exported too

What it does instead
The game quits and logcat shows an error similar to this:

ERROR: No loader found for resource: res://scriptChild.gd

Minimal reproduction project:
I can do it if needed.

@vnen
Copy link
Member

vnen commented May 5, 2018

I think this is expected because you can't know the script dependencies directly. A TSCN or TRES format explicitly list all of it's dependencies, but script files are just code, so you'd need to parse them in order to detect the dependencies.

The preload function is only a convenience to load the resources when loading the script. Since the script is not loaded when exporting, the editor can't really tell what's needed.

@jahd2602
Copy link
Contributor Author

jahd2602 commented May 6, 2018

Yes, it is not implemented right now but it would be very useful. Basically, we would need to parse them the exported scripts recursively at compile/build/export time, and determine it's dependencies from the preload function calls.

I understand that the preload function is only for convenience, but we can use it for more useful things.

@KoBeWi
Copy link
Member

KoBeWi commented Apr 25, 2019

Somewhat related to #26497

@vnen
Copy link
Member

vnen commented Apr 25, 2019

Pretty sure I fixed this for 3.1, scripts now know what their dependencies are (both for preload and extends).

@vnen vnen closed this as completed Apr 25, 2019
@vnen vnen added this to the 3.1 milestone Apr 25, 2019
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