fix: Recompile spritesheet asset and thumbnail when source file is changed#3159
Open
Acissathar wants to merge 1 commit intostride3d:masterfrom
Conversation
…ges to the source are picked up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Details
Modifying a sprite source image (e.g. a PNG) without also modifying the .sdsprite asset file did not trigger recompilation of the SpriteSheet asset or its thumbnail. If you were to add a new sprite to the spritesheet, the thumbnail and spritesheet would update, but removing the sprite would then revert it back to the old one. The workaround was to manually clear the obj/stride cache, but that's very tedious when you're making minor tweaks to a sprite.
The Stride hash is computed from files/content declared via GetInputFiles() but neither SpriteSheetCommand nor SpriteSheetThumbnailCommand overrode GetInputFiles(), so changes to source PNG files were invisible. The actual .sdsheet asset file itself hadn't changed, so it skipped recompilation.
SpriteSheetAssetCompiler.cs:
Added GetInputFiles() to SpriteSheetCommand:
• Packing disabled: Declares the intermediate compiled texture URLs as content dependencies. The prerequisite TextureConvertCommand already tracks the source PNG and re-runs when it changes; by depending on its output, SpriteSheetCommand detects the change transitively and also re-runs.
• Packing enabled: The SpriteSheetCommand loads source PNGs from disk directly, so source files are declared as File inputs directly.
SpriteSheetThumbnailCompiler.cs:
Added GetInputFiles() to SpriteSheetThumbnailCommand, which always reads the sprite source PNG paths from the SpriteSheetAsset parameters and declares them as File inputs. The base implementation's inputs are preserved via base.GetInputFiles().
Now if you make a change to the underlying source it recompile the spritesheet and the thumbnail, so you can immediately run the project and see the updated sprites without having to delete any files or folders.
Related Issue
#791
Types of changes
Checklist