Licensing
A Spine license is required to integrate the Spine Runtimes into your applications.
On-Demand Loading Extension UPM Packages
On-Demand Loading in spine-unity is supported through separate Unity Package Manager (UPM) extension packages. This functionality is especially useful for projects with many skins, where loading all atlas textures up front would significantly increase memory usage and application download size. Instead, textures can be loaded only when needed at runtime.
Two UPM packages are currently available:
- Addressables UPM Package
com.esotericsoftware.spine.addressables
A ready-to-use implementation based on Unity Addressables. - On-Demand Loading UPM Package
com.esotericsoftware.spine.on-demand-loading
A generic infrastructure package for implementing on-demand loading.
Addressables Extension UPM Package
The Spine Addressables plugin adds support for on-demand texture loading to the spine-unity runtime through integration with the Unity Addressables system.
This module covers all necessary steps to automatically replace your textures with low-resolution placeholder versions and loads high-resolution textures on demand. A pre-build step replaces the textures in the build output with their low-resolution counterparts, while a post-build step restores the original high-resolution textures in your project. No additional coding is required.
Installation
The Spine Addressables Extensions package com.esotericsoftware.spine.addressables
depends on the Spine On-Demand Loading Extension package com.esotericsoftware.spine.on-demand-loading
. Please install the On-Demand Loading package before installing the Addressables package.
See section Optional Extension UPM Packages on how to download and install UPM packages and section Updating an Extension UPM Package on how to update them.
Usage
The following steps are all that is required to configure your textures to be replaced with low-resolution placeholders and high-resolution versions loaded automatically on demand.
- Declare your original high-resolution target Material textures as addressable.
- Select the
SpineAtlasAsset
, right-click theSpineAtlasAsset
Inspector heading and selectAdd Addressables Loader
.
- This generates an
AddressableTextureLoader
asset.
- This asset provides configuration parameters and sets up low-resolution placeholder textures which are automatically assigned in a pre-build step when building your game executable.
- Build your Addressables content as usual.
From now on when building your game executable, the low resolution placeholder textures are automatically assigned initially and the corresponding high-resolution textures loaded on-demand.
Editor Preview
Please note that the low-resolution textures are only activated during the game build process. They are not visible in the Unity Editor, including during play mode.
If you'd like to preview the behavior with low-resolution placeholders in the Editor, you can temporarily assign them for testing. To do this, select the desired AddressableTextureLoader
asset and hit Testing
- Assign Placeholders
to temporarily replace the high-resolution textures with their low-resolution placeholders.
You can then observe the high-resolution textures being loaded on-demand during play-mode. Note that this change is for preview purposes only and has no effect on the built game executable. There is no need to manually assign placeholder textures for builds - the system handles this automatically through a pre-build step, with the original textures restored in a post-build step.
On-Demand Loading Extension UPM Package
The core infrastructure for on-demand loading of atlas textures is provided by the separate
Spine On-Demand Loading Extension package com.esotericsoftware.spine.on-demand-loading
. The Spine Addressables plugin (com.esotericsoftware.spine.addressables
) builds upon this foundation and provides a concrete implementation based on the Unity Addressables system.
See section Optional Extension UPM Packages on how to download and install this package and section Updating an Extension UPM Package on how to update it.
You can create custom loading implementations by deriving from GenericOnDemandTextureLoader
and implementing any abstract methods. The AddressablesTextureLoader
class can be used as a reference. If GenericOnDemandTextureLoader
is not a good fit, you can go one step further and derive your own class from OnDemandTextureLoader
and provide a fully custom implementation. This allows for alternative loading strategies tailored to specific project requirements.