Andy

I had 3 files after export from spine (atlas, json, png). Can i load those files from sdcard (Android platform ) then make spine animation at runtime?
Andy
Posts: 3

Pharan

I don't know the details.

But on the Unity side, if you can get the atlas and json string contents, and the png as a Texture2D Unity can use.

Spine-Unity can create a skeleton at runtime from those. There is an example of that in the Spine Examples sample scenes.

The first step has nothing to do with Spine-Unity. You have to look up the Unity API and Android API for how to do it on your device, etc...
User avatar
Pharan

Pharan
Posts: 5366

Andy

Thanks for your reply. After i had searched API of spine, i see spine have func
SkeletonDataAsset.CreateRuntimeInstance(TextAsset,AtlasAsset,true)
But when i create AtlasAsset via
AtlasAsset AtlasAsset = AtlasAsset.CreateRuntimeInstance(TextAsset, Materials, true);
I got this errors log
Error reading atlas file for atlas asset:
Object reference not set to an instance of an object
at Spine.Atlas.ReadTuple (System.IO.TextReader reader, System.String[] tuple) [0x0000b] in E:\GitRepo\Number\Assets\Spine\spine-csharp\Atlas.cs:240
at Spine.Atlas.Load (System.IO.TextReader reader, System.String imagesDir, TextureLoader textureLoader) [0x00073] in E:\GitRepo\Number\Assets\Spine\spine-csharp\Atlas.cs:140
at Spine.Atlas..ctor (System.IO.TextReader reader, System.String dir, TextureLoader textureLoader) [0x00021] in E:\GitRepo\Number\Assets\Spine\spine-csharp\Atlas.cs:107
at Spine.Unity.AtlasAsset.GetAtlas () [0x000a6] in E:\GitRepo\Number\Assets\Spine\spine-unity\Asset Types\AtlasAsset.cs:138
UnityEngine.Debug:LogError(Object, Object)
Spine.Unity.AtlasAsset:GetAtlas() (at Assets/Spine/spine-unity/Asset Types/AtlasAsset.cs:142)
Spine.Unity.AtlasAsset:CreateRuntimeInstance(TextAsset, Material[], Boolean) (at Assets/Spine/spine-unity/Asset Types/AtlasAsset.cs:56)
GameManager:Start() (at Assets/Scripts/GameManager.cs:54)
I make sure all reference have value
Full Code
public TextAsset TextAsset;
public Material[] Materials;
private void Start()
{
SkeletonAnimation skeleton = gameObject.AddComponent<SkeletonAnimation>();
AtlasAsset AtlasAsset = AtlasAsset.CreateRuntimeInstance(TextAsset, Materials, true);
SkeletonDataAsset asset = SkeletonDataAsset.CreateRuntimeInstance(TextAsset, AtlasAsset,true);
skeleton.skeletonDataAsset = asset;
}


---

I realize my mistake, i have to get json atlas when create atlas asset. Everything works well now. :D
Andy
Posts: 3

Pharan

Check the sample scene and sample code for this.
spine-runtimes/DataAssetsFromExportsExample.cs at 3.7-beta
User avatar
Pharan

Pharan
Posts: 5366

Harald

For later reference: Since 3.7 is out of beta, the url is now:
spine-runtimes/DataAssetsFromExportsExample.cs at 3.7
User avatar
Harald

Harri
Posts: 56


Return to Unity