public void changeAnimation(string animationName, float off = 0, bool needBlend = false) { animationData data = dic[animationName]; MaterialPropertyBlock block = new MaterialPropertyBlock(); render.GetPropertyBlock(block); nowTime = -Time.timeSinceLevelLoad; float startNum = data.startNum; float endNum = data.endNum; maxTime = endNum - startNum; isLoop = data.isLoop; if (needBlend) { float oldAnimStart = block.GetFloat("_AnimStart"); float oldAnimEnd = block.GetFloat("_AnimEnd"); float oldAnimOff = block.GetFloat("_AnimOff"); block.SetFloat("_OldAnimStart", oldAnimStart); block.SetFloat("_OldAnimEnd", oldAnimEnd); block.SetFloat("_OldAnimOff", oldAnimOff); block.SetFloat("_Blend", 0f); isBlend = true; } block.SetFloat("_AnimStart", startNum); block.SetFloat("_AnimEnd", endNum); block.SetFloat("_AnimOff", nowTime + off); render.SetPropertyBlock(block); }
private void Awake() { render = transform.GetComponent <Renderer>(); frezzblock = new MaterialPropertyBlock(); blendblock = new MaterialPropertyBlock(); TextAsset text = Resources.Load("AnimationData/" + animationFileName + "AnimationData") as TextAsset; string[] arr1 = text.text.Split('\n'); for (int i = 0; i < arr1.Length; i++) { string[] arr = arr1[i].Split('|'); if (arr.Length < 4) { continue; } animationData data = new animationData(); data.startNum = float.Parse(arr[1]); data.endNum = float.Parse(arr[2]); data.isLoop = bool.Parse(arr[3]); dic[arr[0]] = data; } }
private void loadSkin() { animation = new List <animationData>(); bitmapBlocks = new List <bitmapData>(); textBlocks = new List <textBlockData>(); BinaryReader br = new BinaryReader(meta.MS); BinaryReader br2 = br; #region Animation Frames reflexive br2 = br; br.BaseStream.Position = 20; int animationCount = br.ReadInt32(); int animationOffset = br.ReadInt32() - map.SecondaryMagic; // Handles reflexives in other tags (pointers) int animationTag = map.Functions.ForMeta.FindMetaByOffset(animationOffset); if (animationCount > 0 && animationTag != meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(animationTag, meta.Map, false, true); br2 = new BinaryReader(newMeta.MS); animationOffset -= newMeta.offset; } else { animationOffset -= meta.offset; } for (int list = 0; list < animationCount; list++) { animationData ad = new animationData(list, meta); ad.offset = animationOffset + list * 16; ad.Read(br2); this.animation.Add(ad); } #endregion #region Text blocks reflexive br2 = br; br.BaseStream.Position = 28; int textBlockCount = br.ReadInt32(); int textBlockOffset = br.ReadInt32() - map.SecondaryMagic; // Handles reflexives in other tags (pointers) int textBlockTag = map.Functions.ForMeta.FindMetaByOffset(textBlockOffset); if (textBlockCount > 0 && textBlockTag != meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(textBlockTag, map, false, true); br2 = new BinaryReader(newMeta.MS); textBlockOffset -= newMeta.offset; } else { textBlockOffset -= meta.offset; } for (int list = 0; list < textBlockCount; list++) { textBlockData tbd = new textBlockData(list); tbd.offset = textBlockOffset + list * 44; tbd.Read(br2); this.textBlocks.Add(tbd); } #endregion #region Bitmap block reflexive br.BaseStream.Position = 36; int bitmapBlockCount = br.ReadInt32(); int bitmapBlockOffset = br.ReadInt32() - map.SecondaryMagic; // Handles reflexives in other tags (pointers) int bitmBlockTag = map.Functions.ForMeta.FindMetaByOffset(bitmapBlockOffset); if (bitmapBlockCount > 0 && bitmBlockTag != meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(bitmBlockTag, map, false, true); br2 = new BinaryReader(newMeta.MS); bitmapBlockOffset -= newMeta.offset; } else { bitmapBlockOffset -= meta.offset; } // Always add 3 in case of using sub bitmaps for (int list = 0; list < bitmapBlockCount; list++) { bitmapData bd = new bitmapData(list); bd.offset = bitmapBlockOffset + list * 56; bd.Read(br2); int bitmID = map.Functions.ForMeta.FindMetaByID(bd.bitmIdent); if (bitmID != -1) { bd.meta = Map.GetMetaFromTagIndex(bitmID, map, false, false); ParsedBitmap pm = new ParsedBitmap(ref bd.meta, map); bd.link = pm.FindChunkAndDecode(0, 0, 0, ref bd.meta, map, 0, 0); this.bitmapBlocks.Add(bd); if (pm.Properties.Length > 1) { bd = (bitmapData)bd.Clone(); bd.link = pm.FindChunkAndDecode(1, 0, 0, ref bd.meta, map, 0, 0); } this.bitmapBlocks.Add(bd); if (pm.Properties.Length > 2) { bd = (bitmapData)bd.Clone(); bd.link = pm.FindChunkAndDecode(2, 0, 0, ref bd.meta, map, 0, 0); } this.bitmapBlocks.Add(bd); } } #endregion isLoaded = true; }