[unity] OnDemandTextureLoader: Added TextureLoadFailed callback, used by Addressables extension package.

This commit is contained in:
Harald Csaszar 2024-07-05 12:58:37 +02:00
parent e076a1c7d9
commit 2f44b90878
3 changed files with 12 additions and 1 deletions

View File

@ -89,6 +89,7 @@ namespace Spine.Unity {
public delegate void TextureLoadDelegate (OnDemandTextureLoader loader, Material material, int textureIndex);
protected event TextureLoadDelegate onTextureRequested;
protected event TextureLoadDelegate onTextureLoaded;
protected event TextureLoadDelegate onTextureLoadFailed;
protected event TextureLoadDelegate onTextureUnloaded;
public event TextureLoadDelegate TextureRequested {
@ -99,6 +100,10 @@ namespace Spine.Unity {
add { onTextureLoaded += value; }
remove { onTextureLoaded -= value; }
}
public event TextureLoadDelegate TextureLoadFailed {
add { onTextureLoadFailed += value; }
remove { onTextureLoadFailed -= value; }
}
public event TextureLoadDelegate TextureUnloaded {
add { onTextureUnloaded += value; }
remove { onTextureUnloaded -= value; }
@ -112,6 +117,10 @@ namespace Spine.Unity {
if (onTextureLoaded != null)
onTextureLoaded(this, material, textureIndex);
}
protected void OnTextureLoadFailed (Material material, int textureIndex) {
if (onTextureLoadFailed != null)
onTextureLoadFailed(this, material, textureIndex);
}
protected void OnTextureUnloaded (Material material, int textureIndex) {
if (onTextureUnloaded != null)
onTextureUnloaded(this, material, textureIndex);

View File

@ -87,6 +87,8 @@ namespace Spine.Unity {
materialToUpdate.mainTexture = loadedTexture;
OnTextureLoaded(materialToUpdate, textureIndex);
if (onTextureLoaded != null) onTextureLoaded(loadedTexture);
} else {
OnTextureLoadFailed(materialToUpdate, textureIndex);
}
};
}

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.addressables",
"displayName": "Spine Addressables Extensions [Experimental]",
"description": "This experimental plugin provides integration of Addressables on-demand texture loading for the spine-unity runtime.\nPlease be sure to test this package first and create backups of your project before using.\n\nUsage: First declare your target Material textures as addressable. Then select the SpineAtlasAsset, right-click the SpineAtlasAsset Inspector heading and select 'Add Addressables Loader'. This generates an 'AddressableTextureLoader' asset providing configuration parameters and sets up low-resolution placeholder textures which are automatically assigned in a pre-build step when building your game executable.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime (via the spine-unity unitypackage), version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
"version": "4.2.0-preview.3",
"version": "4.2.0-preview.4",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",