CacheObject.cs 1006 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Animation
  4. {
  5. internal class CacheObject : BaseObject, ISerializationCallbackReceiver
  6. {
  7. public static T Create<T>(Cache owner) where T : CacheObject
  8. {
  9. var cacheObject = CreateInstance<T>();
  10. cacheObject.hideFlags = HideFlags.HideAndDontSave;
  11. cacheObject.owner = owner;
  12. return cacheObject;
  13. }
  14. [SerializeField]
  15. private Cache m_Owner;
  16. public Cache owner
  17. {
  18. get { return m_Owner; }
  19. set { m_Owner = value; }
  20. }
  21. void ISerializationCallbackReceiver.OnAfterDeserialize()
  22. {
  23. OnAfterDeserialize();
  24. }
  25. void ISerializationCallbackReceiver.OnBeforeSerialize()
  26. {
  27. OnBeforeSerialize();
  28. }
  29. internal virtual void OnCreate() {}
  30. protected virtual void OnAfterDeserialize() {}
  31. protected virtual void OnBeforeSerialize() {}
  32. }
  33. }