Addon docs: imported assets need a Godot-exported pack #18
Loading…
Reference in a new issue
No description provided.
Delete branch "hiccup444/da-game-hiccup:addons-docs-imported-assets"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
docs/addons.mdtold addon authors to replace the player arms, or any model, texture or sound, by putting the raw file at the sameres://path inside a.zip. Step 2 of "Making an addon" said to zip that tree. That override never takes effect, in the editor or in an exported build:load()of an imported asset follows the base game's.importfile to the imported copy underres://.godot/imported/..glbor.pngin the pack is never opened and the override silently does nothing.Adding fails the same way. A raw model, texture or sound at a new path in a zip has no
.importfile, soload()cannot find it, and a scene that uses it loads with that resource missing. The README repeated the claim that the base arms are "overridable by any pack".addon_checkcould not catch this. It only overrode files read withFileAccess(aLICENSE.txtand a level JSON) and never calledload()on an imported resource.Both adding and replacing work with a pack exported by Godot. The export carries the
.importfile and the imported data. The imported file name is derived from the source path, so a replacement shadows the base one.Changes
docs/addons.md.glb,.pngor.wavin a zip is ignored at a base path and cannot be loaded at a new one..remapfiles, so raw replacements of those are ignored there too.ProjectSettings.get_global_class_list()went from 125 entries to 0.src/core/addon_loader.gd: the header comment, which says a file in a pack replaces the base file at the same path, now adds thatload()reaches imported assets (and, in an exported game, scenes and scripts) through their.importor.remapfile, so those need a pack exported by Godot.README.md: the base arms are now "replaceable by a pack exported from Godot (a raw.glbin a zip is ignored)" instead of "overridable by any pack". The other README drift is tracked separately.tests/addon_check.gd: a new case that goes throughload(). It uses a small imported texture already in the repo (addons/godot-xr-tools/images/teleport_arrow.png) and a texture at a path the base game does not have. See Tests.This PR only makes the docs honest. The real fix for zip-tier assets is the AssetLoader proposed on #3: key resolution plus runtime loaders (
GLTFDocumentfor glTF,ImagetoImageTexturefor images, WAV from bytes). Until it lands, zip packs can only add or override data the game reads as files, like level JSON, plus new scenes and scripts. When it lands,ArmsViewshould resolve its model through it instead of callingload(MODEL_PATH)directly. Otherwise the arms stay unmoddable by zip even after #3.Tests
New checks in
addon_check:base texture loadsraw asset zip opens,raw asset zip mountsraw texture readable as a file:FileAccessreturns the zip's PNG at the base path, so the pack really is mounted.raw texture in a zip does not change load():load()still returns the base texture.raw texture at a new path is not loadable: the same zip carries the PNG at a new path.FileAccesssees it,ResourceLoader.exists()does not.override texture saves,override .import writes,pck opens,pck writes,imported asset pck mountspck with .import and data replaces load(): the test builds a pck at runtime withPCKPacker. It holds an.importfile at the texture's path, remapped to anImageTexturesaved withResourceSaver. Mounted throughAddonLoader.mount_pack(), it makesload()return the override.pck with .import and data adds a texture at a new path: the same pck also carries that.importfile at the new path, andload()then returns the texture there.throwaway files removed: every pack and temp file is deleted and the test folder is removed. The check fails if any of those removals fails. Nothing is written touser://addons.The new loads use
CACHE_MODE_IGNORE, so a copy cached before mounting cannot hide an override. Mutation runs behaved as expected:.importfile out of the pck fails the matching positive check.Also checked by hand on 4.6.3. These are not part of the suite, since they need
--export-packand a second project:teleport_arrow.pngand a differentplayer_arms.glb.--export-packoutput carriedteleport_arrow.png-f1bd44b6f478277692b3fa29171b62d3.ctexandplayer_arms.glb-cdbc2179235e3e4bc80946aa62fb407a.scn, the same names as the base..zipworked the same way, and no export templates were needed.load()returned the texture, the scene came with it, and the level registry found the descriptor.load()reported "Resource file not found" for a new.png,.glband.wav, and a new scene using the.pngloaded with its texture missing.--main-pack..pngand.glbin a zip were readable as files, butload()kept returning the base texture and arms. The exported addon pack replaced both..tscnand.gdreplacements at base paths were ignored too, because the base.remapfiles point to the converted copies..tscn,.tresand.gdfiles at new paths loaded, and a shadowed level descriptor JSON was read.Full suites (smoke_menu, arms_check, addon_check, save_check, rig_motion_check, pause_check, input_check): all PASS. The local run was on Windows with
--headless --xr-mode off. Every suite's error lines matchmain(the known harness noise only). CI covers Linux.Corrections to the review
.zipexported by Godot works exactly like a.pck. A hand-made zip that carries the.importfile and the data it points to also works. What a raw zip lacks is the import data, not the.pckformat, so the docs say "a pack exported by Godot" rather than "a.pck"..remapfiles. Shadowing those with raw files in a zip only works when running from the project. The docs now say so.Overlap with open PRs
Sibling PRs from the same review: #15, #16, #17 and #19. Their source changes merge cleanly with each other. Several of them add checks at the same spot in
tests/pause_check.gd(and two intests/save_check.gd), so whichever merges second may need a small rebase that keeps both blocks.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.