ClipUpgrade.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. namespace UnityEngine.Timeline
  2. {
  3. partial class TimelineClip
  4. {
  5. enum Versions
  6. {
  7. Initial = 0,
  8. ClipInFromGlobalToLocal = 1
  9. }
  10. const int k_LatestVersion = (int)Versions.ClipInFromGlobalToLocal;
  11. [SerializeField, HideInInspector] int m_Version;
  12. //fields that are used for upgrading should be put here, ideally as read-only
  13. void UpgradeToLatestVersion()
  14. {
  15. if (m_Version < (int)Versions.ClipInFromGlobalToLocal)
  16. {
  17. TimelineClipUpgrade.UpgradeClipInFromGlobalToLocal(this);
  18. }
  19. }
  20. static class TimelineClipUpgrade
  21. {
  22. // version 0->1, clipIn move from global to local
  23. public static void UpgradeClipInFromGlobalToLocal(TimelineClip clip)
  24. {
  25. // case 936751 -- clipIn was serialized in global, not local offset
  26. if (clip.m_ClipIn > 0 && clip.m_TimeScale > float.Epsilon)
  27. clip.m_ClipIn *= clip.m_TimeScale;
  28. }
  29. }
  30. }
  31. }