Hello, while working with Sprite Atlas v2, the version that uses AssetImporter
to import *.spriteatlasv2 files and generates SpriteAtlas : Object
as import artifact.
-
You can specify folders in atlas
Packables
\Objects for Packing
array and atlas will get re-imported whenever content of that folder changed (sprites deleted, added, etc…).
This atlas will have one folder for example:
-
If we open sprite atlas in import activity window
-
We can see that it has dependency called
SourceAsset/HashOfGuidsOfChildren/69cff30118fbd8745952ca6f80dac6b8
where hex at the end is GUID of referenced folder.
Similar dependencies to either import artifact change, or sourсe asset change can be defined in import pipeline with AssetImportContext.DependsOnArtifact(), AssetImportContext.DependsOnSourceAsset() and AssetImportContext.DependsOnCustomDependency(). But I did not found any way to specify dependency to folder content change…
-
I thought that maybe adding dependency with name
SourceAsset/HashOfGuidsOfChildren/{GUID}
by usingAssetImportContext.DependsOnCustomDependency()
might do the trick.
-
But it adds
Environment/CustomDependency/
prefix to dependency path…
-
Possible solution is to manually track all changes to folders with AssetPostprocessor.OnPostprocessAllAssets() and then set custom dependencies values for each folder in project with AssetDatabase.RegisterCustomDependency(). But this way seems convoluted and poorly performing, especially when there is built-in way to do that…
Another solution to get some asset re-imported whenever certain folder changes is to use FileSystemWatcher Class to track required folders, but this also seems weird, and like it might interrupt Unity’s AssetDatabase
IO.
I assume API for adding dependencies for folder content exist only on C++ side, and not presented in any form on C# side. (Atleas I did not found it )
Questions for Unity Employees:
Why does API for adding dependencies for folder contents hashSourceAsset/HashOfGuidsOfChildren/{GUID}
is not exposed?
Is there maybe some hacky way to still add those kind of dependencies?
Are you planing to expose this API in future?