- Изменено
Atlas Assets parameter in SkeletonData asset
Hi,
I'm not sure what the Atlas Assets parameter is for.
Based on documentation:
Atlas references are used by the skeleton to resolve the exported image name references to the respective image areas for rendering.
Upon import the Atlas Assets array is automatically populated with one entry per atlas asset (ending with _Atlas).In case spine-unity failed to automatically assign all required atlas assets, you can change the Atlas Assets Size to the desired amount of atlas assets and manually assign the required atlas assets to Element0 - ElementN.
But when I import the assets into unity and try to modify the size of the array (size parameter), the value goes back to 1 when I press enter.
Dragging another _Atlas asset into the appropriate field in the Inspector also doesn't change anything.
Interestingly, after enabling the Debug mode for the Inspector, I can freely change the value of the size parameter and drag any asset _Atlas.
When exporting a project from Spine, we have the option of creating several atlases that differ in scale (Scale parameter in the Output section) and suffix.
Suppose I want to export an atlas in scale 1 and a second atlas in scale 0.5, with _full and _half suffixes.
The scale 1 atlas consists of several pages, while the 0.5 scale atlas consists of one page.
How will it be handled in Unity during import? My impression is that when I drag all the contents of the exported files from Spine to Unity, one asset _SkeletonData is created and an atlas of scale 1 or 0.5 is randomly assigned.
How should I import these two variants to the project, if I would like to use them, depending on which device the application will be run on (for a weaker device atlas in lower resolution, and for a stronger one in the original size)?
Does the runtime provide an API that allows for the appropriate selection of atlases after starting the application?
I'm using:
Unity 2020.1.4f1
Runtime 4.0.0 for c#
Spine 4.0.64
We are sorry for the inconvenience!
oleg написалBut when I import the assets into unity and try to modify the size of the array (size parameter), the value goes back to 1 when I press enter.
While newer Unity versions (2020.3 and newer) don't immediately revert the array size back when you hit the +
button to extend the arrat, you will indeed also have it automatically re-assigned as soon as you perform a re-import in spine-unity 4.0. Indeed you are right that automatic re-assignment of the primary atlas asset upon re-import is undesired when a different valid atlas asset is already assigned. This behaviour is already improved on spine-unity 4.1-beta, leaving already assigned atlas assets as-is during re-import.
oleg написалHow will it be handled in Unity during import? My impression is that when I drag all the contents of the exported files from Spine to Unity, one asset _SkeletonData is created and an atlas of scale 1 or 0.5 is randomly assigned.
How should I import these two variants to the project, if I would like to use them, depending on which device the application will be run on (for a weaker device atlas in lower resolution, and for a stronger one in the original size)?
Does the runtime provide an API that allows for the appropriate selection of atlases after starting the application?
The atlas asset array is not intended to provide for multiple versions of the same atlas asset, they are only used to resolve your required attachments. If you want to use different assets based on build configurations, then having multiple atlas asset references active while performing a build would be highly wasteful, since all referenced assets are included in the built executable and loaded into memory unnecessarily when running your game.
You need to use an asset pre/post-processor OnPreprocessBuild
script for configuring assets for different build targets. This OnPreprocessBuild
method would need to make sure to prepare your assets accordingly, assigning the desired asset references and clearing undesired ones. Another way would be to create downloadable asset bundles, adressables, etc which are loaded on-demand in the configuration that you need for your platform or graphics settings. Then you need to assign the loaded asset references accordingly.
Unfortunately there is currently no built-in spine-unity component available that automatically downloads and assigns atlas assets, but we have this planned in the following issue ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/1890
FYI: We have just added a commit on the 4.0 branch which fixes the Atlas Assets array immediately resetting in the SkeletionDataAsset Inspector.
A new 4.0 spine-unity package is available on the download page:
spine-unity Download: Older Versions