GroupData.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.ShaderGraph
  4. {
  5. [Serializable]
  6. public class GroupData : ISerializationCallbackReceiver
  7. {
  8. [NonSerialized]
  9. Guid m_Guid;
  10. public Guid guid
  11. {
  12. get { return m_Guid; }
  13. }
  14. public Guid RewriteGuid()
  15. {
  16. m_Guid = Guid.NewGuid();
  17. return m_Guid;
  18. }
  19. [SerializeField]
  20. string m_GuidSerialized;
  21. [SerializeField]
  22. string m_Title;
  23. public string title
  24. {
  25. get{ return m_Title; }
  26. set { m_Title = value; }
  27. }
  28. [SerializeField]
  29. Vector2 m_Position;
  30. public Vector2 position
  31. {
  32. get{ return m_Position; }
  33. set { m_Position = value; }
  34. }
  35. public GroupData(string title, Vector2 position)
  36. {
  37. m_Guid = Guid.NewGuid();
  38. m_Title = title;
  39. m_Position = position;
  40. }
  41. public void OnBeforeSerialize()
  42. {
  43. m_GuidSerialized = guid.ToString();
  44. }
  45. public void OnAfterDeserialize()
  46. {
  47. if (!string.IsNullOrEmpty(m_GuidSerialized))
  48. {
  49. m_Guid = new Guid(m_GuidSerialized);
  50. }
  51. }
  52. }
  53. }