暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.ObjectModel;
  3. using System.IO;
  4. using UnityEngine.Assertions;
  5. namespace UnityEditor.U2D.Aseprite
  6. {
  7. /// <summary>
  8. /// Parsed representation of an Aseprite frame.
  9. /// </summary>
  10. public class FrameData : IDisposable
  11. {
  12. /// <summary>
  13. /// Bytes in this frame.
  14. /// </summary>
  15. public uint noOfBytes { get; private set; }
  16. /// <summary>
  17. /// Frame duration in milliseconds.
  18. /// </summary>
  19. public ushort frameDuration { get; private set; }
  20. /// <summary>
  21. /// Number of chunks.
  22. /// </summary>
  23. public uint chunkCount { get; private set; }
  24. /// <summary>
  25. /// Chunk data for this frame.
  26. /// </summary>
  27. public ReadOnlyCollection<BaseChunk> chunks => Array.AsReadOnly(m_Chunks);
  28. BaseChunk[] m_Chunks;
  29. internal void Read(BinaryReader reader)
  30. {
  31. noOfBytes = reader.ReadUInt32();
  32. var misc0 = reader.ReadUInt16();
  33. var legacyChunkCount = reader.ReadUInt16();
  34. frameDuration = reader.ReadUInt16();
  35. var misc1 = reader.ReadByte();
  36. var misc2 = reader.ReadByte();
  37. var chunkCount = reader.ReadUInt32();
  38. Assert.IsTrue(misc0 == 0xF1FA, "Reading mismatch.");
  39. this.chunkCount = chunkCount != 0 ? chunkCount : legacyChunkCount;
  40. m_Chunks = new BaseChunk[this.chunkCount];
  41. }
  42. internal void SetChunkData(int index, BaseChunk data)
  43. {
  44. if (index < 0 || index >= m_Chunks.Length)
  45. return;
  46. m_Chunks[index] = data;
  47. }
  48. public void Dispose()
  49. {
  50. for (var i = 0; i < m_Chunks.Length; ++i)
  51. m_Chunks[i].Dispose();
  52. }
  53. }
  54. }