I want to create a Spine SkeletonAnimation that uses C#script using Unity3D like this:
public void CreateCharacter()
{
SkeletonAnimation playerAnim;
SkeletonDataAsset playerData;
AtlasAsset atlasdata;
string name = "01_01_ani";
atlasdata = ScriptableObject.CreateInstance ();
playerData = ScriptableObject.CreateInstance ();
atlasdata.atlasFile = (TextAsset)Resources.Load (name + ".atlas");
Material[] materials = new Material[1];
materials [0] = new Material (Shader.Find ("Transparent/Diffuse"));
Texture aa = (Texture)Resources.Load (name);
materials [0].mainTexture = aa;
atlasdata.materials = materials;
playerData.atlasAsset = atlasdata;
playerData.skeletonJSON = (TextAsset)Resources.Load (name + ".json");
GameObject player = new GameObject();
player.transform.localPosition = Vector3.zero;
player.transform.localScale = new Vector3 (1f, 1f, 1f);
playerAnim = (SkeletonAnimation)player.AddComponent ("SkeletonAnimation");
playerAnim.skeletonDataAsset = playerData;
playerAnim.calculateNormals = true;
playerAnim.AnimationName = "running";
playerAnim.loop = true;
}
But It brought on an error like this:
"Missing SkeletonData asset."
"NullReferenceException: Object reference not set to an instance of an object"
"ArgumentException: Getting control 1's position in a group with only 1 controls when doing Repaint
Aborting"
I would like to find out what the problem with this such method and would like to know how to create a Spine Skeleton Animation using C#script from Unity3D?
Is there any other way(other than the method I used)to create a Spine Skeleton Animation using C#script from Unity3D?
Thanks in advance.
↧