AnimationTrackUpgrade.cs
5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using System.ComponentModel;
namespace UnityEngine.Timeline
{
partial class AnimationTrack
{
// 649 is value is only assigned to. they can be updated from old files being serialized
#pragma warning disable 649
//fields that are used for upgrading should be put here, ideally as read-only
[SerializeField, Obsolete("Use m_InfiniteClipOffsetEulerAngles Instead", false), HideInInspector]
Quaternion m_OpenClipOffsetRotation = Quaternion.identity;
[SerializeField, Obsolete("Use m_RotationEuler Instead", false), HideInInspector]
Quaternion m_Rotation = Quaternion.identity;
[SerializeField, Obsolete("Use m_RootTransformOffsetMode", false), HideInInspector]
bool m_ApplyOffsets;
#pragma warning restore 649
/// <summary>
/// Translation offset of a track in infinite mode.
/// This property is obsolete. Use <see cref="UnityEngine.Timeline.AnimationTrack.infiniteClipOffsetPosition"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("openClipOffsetPosition has been deprecated. Use infiniteClipOffsetPosition instead. (UnityUpgradable) -> infiniteClipOffsetPosition", true)]
public Vector3 openClipOffsetPosition
{
get { return infiniteClipOffsetPosition; }
set { infiniteClipOffsetPosition = value; }
}
/// <summary>
/// Rotation offset of a track in infinite mode.
/// This property is obsolete. Use <see cref="UnityEngine.Timeline.AnimationTrack.infiniteClipOffsetRotation"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("openClipOffsetRotation has been deprecated. Use infiniteClipOffsetRotation instead. (UnityUpgradable) -> infiniteClipOffsetRotation", true)]
public Quaternion openClipOffsetRotation
{
get { return infiniteClipOffsetRotation; }
set { infiniteClipOffsetRotation = value; }
}
/// <summary>
/// Euler angle representation of the rotation offset of the track when in infinite mode.
/// This property is obsolete. Use <see cref="UnityEngine.Timeline.AnimationTrack.infiniteClipOffsetEulerAngles"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("openClipOffsetEulerAngles has been deprecated. Use infiniteClipOffsetEulerAngles instead. (UnityUpgradable) -> infiniteClipOffsetEulerAngles", true)]
public Vector3 openClipOffsetEulerAngles
{
get { return infiniteClipOffsetEulerAngles; }
set { infiniteClipOffsetEulerAngles = value; }
}
/// <summary>
/// Saved state of pre-extrapolation for clips converted to infinite mode.
/// This property is obsolete. Use <see cref="UnityEngine.Timeline.AnimationTrack.infiniteClipPreExtrapolation"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("openClipPreExtrapolation has been deprecated. Use infiniteClipPreExtrapolation instead. (UnityUpgradable) -> infiniteClipPreExtrapolation", true)]
public TimelineClip.ClipExtrapolation openClipPreExtrapolation
{
get { return infiniteClipPreExtrapolation; }
set { infiniteClipPreExtrapolation = value; }
}
/// <summary>
/// Saved state of post-extrapolation for clips converted to infinite mode.
/// This property is obsolete. Use <see cref="UnityEngine.Timeline.AnimationTrack.infiniteClipPostExtrapolation"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("openClipPostExtrapolation has been deprecated. Use infiniteClipPostExtrapolation instead. (UnityUpgradable) -> infiniteClipPostExtrapolation", true)]
public TimelineClip.ClipExtrapolation openClipPostExtrapolation
{
get { return infiniteClipPostExtrapolation; }
set { infiniteClipPostExtrapolation = value; }
}
internal override void OnUpgradeFromVersion(int oldVersion)
{
if (oldVersion < (int)Versions.RotationAsEuler)
AnimationTrackUpgrade.ConvertRotationsToEuler(this);
if (oldVersion < (int)Versions.RootMotionUpgrade)
AnimationTrackUpgrade.ConvertRootMotion(this);
if (oldVersion < (int)Versions.AnimatedTrackProperties)
AnimationTrackUpgrade.ConvertInfiniteTrack(this);
}
// 612 is Property is Obsolete
// 618 is Field is Obsolete
#pragma warning disable 612, 618
static class AnimationTrackUpgrade
{
public static void ConvertRotationsToEuler(AnimationTrack track)
{
track.m_EulerAngles = track.m_Rotation.eulerAngles;
track.m_InfiniteClipOffsetEulerAngles = track.m_OpenClipOffsetRotation.eulerAngles;
}
public static void ConvertRootMotion(AnimationTrack track)
{
track.m_TrackOffset = TrackOffset.Auto; // loaded tracks should use legacy mode
// reset offsets if not applied
if (!track.m_ApplyOffsets)
{
track.m_Position = Vector3.zero;
track.m_EulerAngles = Vector3.zero;
}
}
public static void ConvertInfiniteTrack(AnimationTrack track)
{
track.m_InfiniteClip = track.m_AnimClip;
track.m_AnimClip = null;
}
}
#pragma warning restore 612, 618
}
}