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

Paths with "//" instead of "/" works in editor but not in export #52507

Closed
gdesecrate opened this issue Sep 9, 2021 · 3 comments · Fixed by #52513
Closed

Paths with "//" instead of "/" works in editor but not in export #52507

gdesecrate opened this issue Sep 9, 2021 · 3 comments · Fixed by #52513
Milestone

Comments

@gdesecrate
Copy link

Godot version

3.3.3.stable

System information

Manjaro 21.1.1 Pahvo, GLES2, Radeon RX 5500 XT (NAVI14, DRM 3.40.0, 5.10.60-1-MANJARO, LLVM 12.0.1)

Issue description

If you use "//" in file name instead of "/" while in editor and run - all works fine.
If you export project - it would won't work anymore.

Accidentally hit this issue because I was constructing file path with string operations.

Steps to reproduce

  1. Use "//" instead of "/" in address on file, like "res://folder//folder//folder//icon.png"
  2. use this address to load() something
  3. It would work while running from editor
  4. It won't work after export

Minimal reproduction project

New Game Project.zip

@aleksfadini
Copy link

aleksfadini commented Sep 17, 2021

Is there any workaround that comes to mind?

I ran into this issue in a singleton where I preload all the assets in a folder with a loop similar to this:

`
[...]
elif file.ends_with(".mp3"):
var loop=preload("res://"+file)
if file.begins_with("Drums"):
drum_loops.append(loop)
[...]

`

How do I avoid using the double slash and getting the same result?
Nothing gets loaded in the exported file on android or osx. I'm a bit desperate

@Calinou
Copy link
Member

Calinou commented Sep 17, 2021

Is there any workaround that comes to mind?

file.replace("//", "/") (assuming file is a String path) should do the trick 🙂

@aleksfadini
Copy link

aleksfadini commented Sep 17, 2021

Didn't seem to do the trick reliably.

file.replace("//", "/") seems to crash the app on mac OS export, and resources just won't load on android.
It used to work before, and my mobile app is in production. Panic!
On export, some things get loaded, some others do not. Maybe it has to do with how the strings are composited. I have been testing for hours, your solution works for a simple test.
Any other idea?

I want to point out that these issue happens even when loading any regular path that starts with "res://" in gdscript

EDIT: fixed
at times I had to use

file=file.replace("//", "/")

very clunky, but thanks for putting me on the right path

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

Successfully merging a pull request may close this issue.

4 participants