/// <returns>The atlas or null if it could not be loaded.</returns> public Atlas GetAtlas() { if (atlasFile == null) { Debug.LogError("Atlas file not set for atlas asset: " + name, this); Clear(); return null; } if (materials == null || materials.Length == 0) { Debug.LogError("Materials not set for atlas asset: " + name, this); Clear(); return null; } if (atlas != null) return atlas; try { atlas = new Atlas(new StringReader(atlasFile.text), "", new MaterialsTextureLoader(this)); atlas.FlipV(); return atlas; } catch (Exception ex) { Debug.LogError("Error reading atlas file for atlas asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this); return null; } }
void OnCurLoadFinish() {//先临时验证一下代码构造spine动画,两个atlas的设计问题较多,必须要休整一下播放组件 GameObject curObj = new GameObject(); curObj.name = "spine-cur"; SkeletonAnimationCL ani = curObj.AddComponent <SkeletonAnimationCL>(); //AtlasAsset assAtlas = new AtlasAsset(); //assAtlas.materials = new Material[1]; //assAtlas.materials[0] = new Material(Shader.Find("Spine/Skeleton")); //assAtlas.materials[0].mainTexture = curAtlasTex; Dictionary <string, Texture2D> texs = new Dictionary <string, Texture2D>(); texs["cur.png"] = curAtlasTex; var atlas = new Spine.Atlas(new System.IO.StringReader(curAtlas), "", new TextureLoad(texs)); atlas.FlipV(); //assAtlas.SetAtlas(atlas); Spine.SkeletonJson sjson = new Spine.SkeletonJson(atlas); sjson.Scale = 1.0f / 64.0f; var data = sjson.ReadSkeletonData(new System.IO.StringReader(curSK)); ani.skeleton = new Spine.Skeleton(data); ani.Reset(); ani.state.SetAnimation(0, "idle", true); }
void OnCurLoadFinish() { //先临时验证一下代码构造spine动画,两个atlas的设计问题较多,必须要休整一下播放组件 GameObject curObj=new GameObject(); curObj.name="spine-cur"; SkeletonAnimationCL ani = curObj.AddComponent<SkeletonAnimationCL>(); //AtlasAsset assAtlas = new AtlasAsset(); //assAtlas.materials = new Material[1]; //assAtlas.materials[0] = new Material(Shader.Find("Spine/Skeleton")); //assAtlas.materials[0].mainTexture = curAtlasTex; Dictionary<string, Texture2D> texs = new Dictionary<string, Texture2D>(); texs["cur.png"] = curAtlasTex; var atlas = new Spine.Atlas(new System.IO.StringReader(curAtlas), "", new TextureLoad(texs)); atlas.FlipV(); //assAtlas.SetAtlas(atlas); Spine.SkeletonJson sjson = new Spine.SkeletonJson(atlas); sjson.Scale = 1.0f/64.0f; var data=sjson.ReadSkeletonData(new System.IO.StringReader(curSK)); ani.skeleton = new Spine.Skeleton(data); ani.Reset(); ani.state.SetAnimation(0, "idle", true); }