• Unity
  • "Include in build" setting doesn't work when using unity-atl

I wanna have a smaller atlas-variant in a build in some circumstances, but seems "include in build" setting has no effect. Is there a way to make it run?

Related Discussions
...

I'm not sure at which asset you have set the include in build setting. Could you please describe in other words what you want to achieve, and what you have tried so far?

In my case it is needed to have two sizes of same atlases for unity addressable system. So I have master atlases and atlas variants and I build addressable bundles twice. First time I include in the build master atlases and second time I include variants that are half of original size. I wanted to turn spine-atlases into unity-atlases expecting that I can include their variants in the same way as I do for rest of atlases. But before doing that I created test-project to see how it's gonna be. I made the skeleton to utilize a unity-atlas instead of native one as described here: http://esotericsoftware.com/spine-unity#Advanced


Using-Unity-SpriteAtlas-as-Atlas-Provider
Then I created smaller variant of that unity-atlas. I tried to include in build only variant but I found that there is the master atlas in the build instead.

Thanks for the additional info. One problem is that the Unity SpriteAtlas integration is required to generate a single .png atlas texture first, which will be used in the Unity Editor instead of the SpriteAtlas asset (limitations in the Unity SpriteAtlas API made this necessary). You can see this texture assigned at the generated SpineSpriteAtlasAsset named <atlas name>_SpriteAtlas, which holds a reference to a single material in the Inspector (the material is also named <atlas name>_SpriteAtlas). This Material references the generated atlas texture named <atlas name>. This material reference might cause an additional unnecessary inclusion of a full-resolution atlas texture, increasing the build-size of your executable no matter if include in build is enabled or not.

We have an issue ticket here to improve the current implementation of the the Unity SpriteAtlas integration:
https://github.com/EsotericSoftware/spine-runtimes/issues/1900
I have just uploaded a fix on the 4.1-beta branch (and a new spine-unity package available on the download page) which removes the material references to the generated .png atlas texture file when building the game, which is only needed in the Unity Editor but not in the build. If you need to use spine-unity 4.0, you should be able to only import the SpineBuildProcessor.cs file from the 4.1 unitypackage to include this update. Does this improve the situation in your case? I assume however that this does not yet resolve your problem, is this correct?

If your problem still persists after this upgrade, could you please send us a minimal Unity project that still demonstrates this problem? You can send it as a zip package to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we can have a look at it.

I will try that soon and let you know. Thank you for such a wide answer.

I have decided to officially include the above commit also on the 4.0 branch (and not only on 4.1-beta), since it also fixes one other build issue. So you can download the latest 4.0 spine-unity package and have these changes integrated already:
Spine Unity Download: Download

I looked throught your improvement, thanks for pointing it out, but it's not what I meant) I just wanted to have convenient way to include into build the same textures but of different size. Kinda big textures for big screens, and smaller for small screens to be able then to download corresponding bundles in run time basing on screen info. But now I realize that unity-atlases have nothing to do with that in case of spine coz spine just generates needed assets based on unity-atlases and then utilizes that assets. So does not metter if unity-atlas included in build or not. The easiest workaround I see is just not messing with unity-atlases but adjast Max Size of spine-atlas-textures for different bundles. Not such a convenient way but it works. Anyway thanks for help)

Serhii a écrit

But now I realize that unity-atlases have nothing to do with that in case of spine coz spine just generates needed assets based on unity-atlases and then utilizes that assets.

I think I haven't explained the Unity SpriteAtlas integration behaviour well enough, as what you described might work in the Unity Editor but is expected to fail in the built executable.

The generated atlas texture (named <atlas name>.png) is used in the Editor, also when entering Play mode. However, when building the game executable and playing the game, this atlas texture is not used. Instead, Unity's internally generated atlas is used (accessed through the Sprite references, which works at runtime). If for example you paint the generated texture red, you will see it used in the Editor, but not after building the game and running the game executable.

Unfortunately the generated atlas texture is necessary for the Editor when outside of Play mode due to the limited Unity API, we would have avoided it if that was possible.

In short: the SpriteAtlas is used in the built game executable, even if it does not look like it in the Editor.