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. 😃