"DependencyRetargeterPlugin" as a way to hook into the save/load process of ResourceLoader/Saver, in order to customise how external dependencies are referenced (and loaded) #12721
MarioBossReal
started this conversation in
Engine Core
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been recently working on my game, which makes use of a "soft reference" system for external resource dependencies.
Instead of using direct paths for subresources (like "res://content_source/materials/mymat.material"), it uses "soft paths" ("materials/mymat.material"), which are then resolved by a custom AssetSystem which handles the mounting of base directories and PCKs. This is sort of how games like cs2 and half-life alyx work, by loading compiled content into their various content creation tools so that they can be used in the creation of assets such as maps. This has worked well for resources that I compile to a custom format for packaging, as I have full control over the entire file and how reference paths are stored and loaded from (ResourceFormatLoader/Saver). However, it doesn't really work for regular godot resources (res/tres/scn/tscn) which are used internally, as there is no way to hook into the save/load process to intercept the saving and loading of subresources. There is no way that I can say for example, reference a mesh file in a standard custom resource, and then when saving that custom resource have the path which points to the mesh dependency be modified (and vice-versa, when loading the standard custom resource, be able to hook into the dependency loading process to retarget the saved filepath).
(Essentially, the highlighted filepath needs to be customisable, both in loading and saving)
I believe this can be fixed by introducing a new plugin class to extend from, which is called both whenever a resource is saving references (filepaths) to external resources, as well as whenever a resource is about to load an external dependency.
For example:
I decided to open a discussion rather than a proposal as I'd like to hear thoughts on if this could be done in a better way, or if there is already a way to do this in the engine that I have missed. I tried making a hacky version of this by abusing ResourceFormatLoader and ResourceFormatSaver to intercept the saving and loading of standard resources, and storing custom paths as metadata, but this didn't end up working well and its a really terrible and hacky solution regardless.
Beta Was this translation helpful? Give feedback.
All reactions