-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
On export, every .tres
file is renamed to .tres.remap
#66014
Comments
It looks like all the
This is pretty problematic because there're definitely use cases where you want to dynamically load files in a directory, but now they're all remapped. Ideally, |
I was able to work around this like so: while(file_name != ""):
if dir.current_is_dir():
var newDir = Directory.new()
load_resource("{0}/{1}".format([path, file_name]), newDir, array, dict)
elif dir.file_exists("{0}/{1}".format([path, file_name])) and '.tres' in file_name:
if '.tres.remap' in file_name: # <---- NEW
file_name = file_name.trim_suffix('.remap') # <---- NEW
var r = load("{0}/{1}".format([path, file_name]))
if array != null:
array.append(r)
if dict != null:
dict[r.id] = r
file_name = dir.get_next() However, this doesn't feel like the right approach for all users. I think adding the ability to |
Specifying There have been long standing issues with dynamically generated names on export, eg. And here was a proposed solution for those issues You can try changing your project settings to enable
|
This also happens on ".tscn" scenes I tried loading in runtime, a simple "Levels" directory inside my project with all the level scenes. I get a I feel this is really unintuitive for users. A "Levels" directory is even an example Godot gives in its own documentation (on |
…odotengine/godot#66014 This might be fixed by Godot in the future and this change should be reverted
…odotengine/godot#66014 This might be fixed by Godot in the future and this change should be reverted
I was meeting this bug too. And it's take my so many time to debug, because my code was work correct in editor bug can't work when exported.
|
Adding that this is still an issue in 4.0 beta 2 and is really unintuitive to fix: Code:
|
I'm also experiencing this issue on 4.0 beta 7 ios export. |
if '.tres.remap' in file_name: # <---- NEW
file_name = file_name.trim_suffix('.remap') # <---- NEW Its also possible to simply |
This also affects tscn files now too... it is like the .import issue and the .gdc issue, Godot needs to have a file access method that works like a virtual one, that can remember the way the files were when we are developing the game, as compared to having to hack around all of the ways in which the engine edits our files. Also I though .godot folder was going to fix this issue? See #42507 & #25672
|
This is intentional, and the usability issue around trying to load such files with |
Still an issue in Godot 4.0.2.stable when exporting for android, at least for if file_name.ends_with(".remap"):
file_name = file_name.trim_suffix(".remap") |
This is STILL an issue. Tested in Godot 4.1.3. |
Umm, why would you intentionally make such a function do this? Why not VERY SIMPLY add |
This happens because scenes and resources are exported in the binary format by default, see Understand that the actual So there's no bug here but intended behaviour, and the linked issue is about how to improve usability with regards to searching and accessing files in the exported project 🙂 |
@AThousandShips I can't seem to find the best practice if we want to load all resource files from a folder without having to manually update them everytime we add or remove one? The workaround just feels hacky. Any ideas? |
I don't know in this case, but see #25672 |
@richardbonneau I made an addon to solve this problem. With the addon you define a "resource group" (which is a new resource type) which contains a list of patterns (e.g. folder/**/*.tres) and which will automatically maintain a list of resources matching that pattern (you can add exclude patterns as well). Then in your code you can get all the resources in the group like this: var resource_group:ResourceGroup = load("res://path/to/resource_group.tres")
var all_resources_in_the_group:Array[Resource] = resource_group.load_all() The list is maintained by an editor plugin so it doesn't rely on any non-documented file mapping that Godot applies on export. It will also not do any file system scans when you call |
This issue still persists in v4.2.2.stable.official [15073af] |
The issue isnt an issue and hasnt been "fixed". |
I had to read the whole thread to finally understand that Use What about I will share my specific case so people can realize it: I have a directory for skills (RPG game). skills that apply stats boost may have a companion
The second is optional, and not referenced in At battle screen loading, there is a Original code that misuse func load_skill (res_name):
var filename = "res://skills/" + res_name + ".tres"
if FileAccess.file_exists(filename):
var skill = load(filename)
SKILLS[res_name] = skill
var stats_filename = "res://skills/" + res_name + "_stats.tres"
if FileAccess.file_exists(stats_filename):
skill.stats = load(stats_filename)
else:
print("WARNING: load_skill: requested skill doesn't exist: " + res_name) Correct code. Use func load_skill (res_name):
var filename = "res://skills/" + res_name + ".tres" # No need for weird string manipulation
var skill = load(filename)
if skill:
SKILLS[res_name] = skill
var influence_stats = load("res://skills/" + res_name + "_stats.tres")
if influence_stats:
skill.stats = influence_stats
else:
# Good place for assert, but we have a bunch of non existent skills right now
# and we want to test the game, so we just allow it to continue for now.
print("WARNING: load_skill: requested skill doesn't exist: " + res_name) At battle scene loading, you call this function as there are unique skills in all units participating in the battle. If you have the following unique skills |
@ElAbuelo2 I think the problem isn't about loading the resource, at least for me. Godot on default changes all The simplest solution is to just disable |
@myin142 If I got this right, But maybe I got this wrong, and this only works if path starts with "res://" protocol. In that case, mixing I understand you are getting a list of filenames all ending with ".remap". And I understand we want to just walk that list with a I have many projects using Godot. Mainly prototypes. And this is the first time I had problems of this sort, only because I finally mixed Said in another way, of these three:
I'm sure number 1 will try for ".tres.remap" version if ".tres" doesn't exist and just work. Number 4 will surely fail, even if ".remap" version exists. And I wonder about the other two. |
There just doesn't seem to be a clear way on how to load resources dynamically on runtime. What I don't like about changing the path manually is, that you have to know the specifics on how Godot handles these files and who knows if they will change it in the future or not. Having it behave differently when developing and on export is just making it confusing. I already have encountered problems on export multiple times. By using just one simple option to fix all that is at least worth it for me. It's even documented in But I'm questioning anyway if I should use resources at all, since I could write it all in a script directly.. |
So after all this, can we agree that this is not a design issue, but an issue with the overall implicit usability and compatibility of the system's internals? Godot should be doing everything in it's power to maintain the mapping that the developer has in their mind about where things should be in the filesystem (even if that means just storing a literal dictionary of mappings somewhere ( |
I think it's better to add some API for For another workaround, you can always build an index for your resources in game, and scan the index instead (that's what I always do both in Godot and Unity). |
Okay, just ran into this myself with 4.2.2.stable. Seriously, if all is needed is to remove the .remap suffix (which is an implementation detail), why doesn't ResourceLoader just do that for us under the hood? This would give the Godot devs more freedom to change how they want to handle these paths and it abstracts away this detail from us Godot users so that our projects don't break if/when the implementation changes (say, the Godot devs what to use some other mechanism than adding .remap suffix to the paths)? Or at least implement a ResourceLoader.get_files_in_dir() function to support this as previously suggested here. I love Godot as a nice piece of software but this has me raising my brow to be honest. It's a no-brainer to abstract these kinds of details from the user and to ensure the 2 API's (ResourceLoader and DirAccess/FileAccess) are compatible. Perhaps this could be a good "first time" issue a new contributor could implement. Also, is there a list of such suffixes (.import, .remap, etc.) we can use as reference to make sure our projects work after export? |
I had this exact same issue. I fixed the issue completely by turning off |
I just ran into this issue attempting to dynamically load level resources. I didn't see any mention of this in the docs but i might have missed it. Very new to Godot btw. Overall great experience so far but this was a bit of a head stratcher. |
Godot version
4.0 Beta 1
System information
Mac OS
Issue description
When exporting my game in Godot 4, every
.tres
file is exported as.tres.remap
This means that I can't callload(resource)
because Godot throws:ERROR: No loader found for resource: res://Resources/Items/Seeds/AutumnWingsGourdSeeds.tres.remap.
I think this started around Godot 4 - Alpha 16
I'm not sure what the cause is, and there is very little information available online about
.tres.remap
files.Steps to reproduce
Here's the sample code I'm using to encounter this:
The goal is to load all the animals at run time and store them in an array & dict in memory for later use. This worked in Godot 3 and much of the 4 Alphas, but has stopped working for me recently.
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: