StickyNoteData.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.ShaderGraph
  4. {
  5. [Serializable]
  6. class StickyNoteData : ISerializationCallbackReceiver, IGroupItem
  7. {
  8. [NonSerialized]
  9. Guid m_Guid;
  10. public Guid guid => m_Guid;
  11. [SerializeField]
  12. string m_GuidSerialized;
  13. public Guid RewriteGuid()
  14. {
  15. m_Guid = Guid.NewGuid();
  16. return m_Guid;
  17. }
  18. [SerializeField]
  19. string m_Title;
  20. public string title
  21. {
  22. get => m_Title;
  23. set => m_Title = value;
  24. }
  25. [SerializeField]
  26. string m_Content;
  27. public string content
  28. {
  29. get => m_Content;
  30. set => m_Content = value;
  31. }
  32. [SerializeField]
  33. int m_TextSize;
  34. public int textSize
  35. {
  36. get => m_TextSize;
  37. set => m_TextSize = value;
  38. }
  39. [SerializeField]
  40. int m_Theme;
  41. public int theme
  42. {
  43. get => m_Theme;
  44. set => m_Theme = value;
  45. }
  46. [SerializeField]
  47. Rect m_Position;
  48. public Rect position
  49. {
  50. get => m_Position;
  51. set => m_Position = value;
  52. }
  53. [SerializeField]
  54. string m_GroupGuidSerialized;
  55. [NonSerialized]
  56. Guid m_GroupGuid;
  57. public Guid groupGuid
  58. {
  59. get { return m_GroupGuid; }
  60. set { m_GroupGuid = value; }
  61. }
  62. public StickyNoteData(string title, string content, Rect position)
  63. {
  64. m_Guid = Guid.NewGuid();
  65. m_Title = title;
  66. m_Position = position;
  67. m_Content = content;
  68. m_GroupGuid = Guid.Empty;
  69. }
  70. public void OnBeforeSerialize()
  71. {
  72. m_GuidSerialized = guid.ToString();
  73. m_GroupGuidSerialized = groupGuid.ToString();
  74. }
  75. public void OnAfterDeserialize()
  76. {
  77. if (!string.IsNullOrEmpty(m_GuidSerialized))
  78. {
  79. m_Guid = new Guid(m_GuidSerialized);
  80. }
  81. if (!string.IsNullOrEmpty(m_GroupGuidSerialized))
  82. {
  83. m_GroupGuid = new Guid(m_GroupGuidSerialized);
  84. }
  85. }
  86. }
  87. }