PSDLayer.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using Unity.Collections;
  3. using UnityEngine;
  4. namespace UnityEditor.U2D.PSD
  5. {
  6. [Serializable]
  7. class PSDLayer
  8. {
  9. [SerializeField]
  10. string m_Name;
  11. [SerializeField]
  12. string m_SpriteName;
  13. [SerializeField]
  14. bool m_IsGroup;
  15. [SerializeField]
  16. int m_ParentIndex;
  17. [SerializeField]
  18. string m_SpriteID;
  19. [SerializeField]
  20. int m_LayerID;
  21. [SerializeField]
  22. Vector2Int m_MosaicPosition;
  23. [NonSerialized]
  24. GameObject m_GameObject;
  25. public PSDLayer(NativeArray<Color32> tex, int parent, bool group, string layerName, int width, int height, int id)
  26. {
  27. isGroup = group;
  28. parentIndex = parent;
  29. texture = tex;
  30. name = layerName;
  31. this.width = width;
  32. this.height = height;
  33. layerID = id;
  34. }
  35. public int layerID { get { return m_LayerID; } private set { m_LayerID = value; } }
  36. public string name { get { return m_Name; } private set { m_Name = value; } }
  37. public string spriteName { get { return m_SpriteName; } set { m_SpriteName = value; } }
  38. public bool isGroup { get { return m_IsGroup; } private set { m_IsGroup = value; } }
  39. public int parentIndex { get { return m_ParentIndex; } private set { m_ParentIndex = value; } }
  40. public Vector2Int mosaicPosition { get { return m_MosaicPosition; } set { m_MosaicPosition = value; } }
  41. public GUID spriteID { get { return new GUID(m_SpriteID); } set { m_SpriteID = value.ToString(); } }
  42. public GameObject gameObject { get { return m_GameObject; } set { m_GameObject = value; } }
  43. public NativeArray<Color32> texture { get; set; }
  44. public int width { get; private set; }
  45. public int height { get; private set; }
  46. public void Dispose()
  47. {
  48. if (texture.IsCreated)
  49. texture.Dispose();
  50. }
  51. }
  52. }