Hi,
I'm having problemw with my animated objects, I'm instantiating many objects with the Skeleton Graphic script, I'm also setting their starting animation, loop mode, etc... Everything during runtime.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Spine.Unity;
public class Script_SkeletonSet : MonoBehaviour
{
public Script_InGameOBJ Ref_ScriptOBJ; // Script with data
public SkeletonGraphic Ref_SkeletonGraph;
private void OnEnable()
{
Ref_SkeletonGraph.skeletonDataAsset = Resources.Load<SkeletonDataAsset>("Skeleton_" + Ref_ScriptOBJ.Nombre + "/Skeleton_" + Ref_ScriptOBJ.Nombre);
Ref_SkeletonGraph.startingAnimation = "idle";
}
private void Start()
{
Ref_SkeletonGraph.startingLoop = true;
Ref_SkeletonGraph.AnimationState.SetAnimation(0, "idle", true);
}
}
Is everything okay with that code? Because during runtime the objects are like... Stuck? They only show their atlas, but as soon as I click anything on their inspector (Freeze, Flip, Starting loop) during runtime they switch to the proper animation "idle".
I'll provide more information if needed, thanks for reading.
EDIT 20/04:
Just tried this:
using UnityEngine;
using Spine.Unity;
public class Script_SpineTest : MonoBehaviour
{
public SkeletonGraphic Ref_SkeletonGraph;
public SkeletonDataAsset Ref_SkeletonData;
private void Start()
{
Ref_SkeletonGraph = this.gameObject.GetComponent<SkeletonGraphic>();
Ref_SkeletonData = Resources.Load<SkeletonDataAsset>("Skeleton_Orange/Skeleton_Orange");
Ref_SkeletonGraph.skeletonDataAsset = Ref_SkeletonData;
Debug.Log(Ref_SkeletonData);
Ref_SkeletonGraph.AnimationState.SetAnimation(0,"idle", true); // Causing NullReferenceException
}
}
But now I'm getting NullReference from SetAnimation if I don't set the SkeletonDataAsset before entering Play Mode.
EDIT 2 20/04:
Fixed, all I needed was to call Ref_SkeletonGraph.Initialize(false); again because of the returns from SkeletonGraphic.cs during Awake.