-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDOTweenClip.cs
More file actions
105 lines (91 loc) · 4.36 KB
/
DOTweenClip.cs
File metadata and controls
105 lines (91 loc) · 4.36 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
// MIT License
// Copyright (c) 2024 Breakstep Studios
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using DG.Tweening;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
namespace _Game_Assets.Scripts.Runtime.Unity_Timeline
{
/// <summary>
/// The clip that contains the data that we will use when animating our DOTween
/// </summary>
[Serializable]
public class DOTweenClip : PlayableAsset, ITimelineClipAsset
{
/// <summary>
/// If true will allow us to tween our current position to a target position.
/// </summary>
[Tooltip("If true will allow us to tween our current position to a target position.")]
public bool tweenPosition;
/// <summary>
/// The position we will tween to, if tweenPosition is enabled.
/// </summary>
[Tooltip("The position we will tween to, if tweenPosition is enabled.")]
[ShowIf("tweenPosition")]
public Vector3 targetPosition;
/// <summary>
/// If true will allow us to tween our current rotation to a target rotation.
/// </summary>
[Tooltip("If true will allow us to tween our current rotation to a target rotation.")]
public bool tweenRotation;
/// <summary>
/// The rotation we will tween to, if tweenRotation is enabled.
/// </summary>
[Tooltip("The rotation we will tween to, if tweenRotation is enabled. ")]
[ShowIf("tweenRotation")]
public Vector3 targetRotation;
/// <summary>
/// If true will allow us to tween our current scale to a target scale.
/// </summary>
[Tooltip("If true will allow us to tween our current scale to a target scale.")]
public bool tweenScale;
/// <summary>
/// The scale we will tween to, if tweenScale is enabled.
/// </summary>
[Tooltip("The scale we will tween to, if tweenScale is enabled.")]
[ShowIf("tweenScale")]
public Vector3 targetScale;
/// <summary>
/// The ease that we will use for both our tweenPosition and tweenRotation
/// </summary>
[Tooltip("The ease that we will use for both our tweenPosition and tweenRotation")]
public Ease ease;
/// <summary>
/// If true the target values will not be reset when the clip ends, otherwise target will have values reset to those of when the clip began.
/// </summary>
[Tooltip("If true the target values will not be reset when the clip ends, otherwise target will have values reset to those of when the clip began.")]
public bool retainTargetValues;
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable<DOTweenBehavior>.Create(graph);
var tween = playable.GetBehaviour();
tween.tweenPosition = tweenPosition;
tween.targetPosition = targetPosition;
tween.tweenRotation = tweenRotation;
tween.targetRotation = targetRotation;
tween.tweenScale = tweenScale;
tween.targetScale = targetScale;
tween.ease = ease;
tween.retainTargetValues = retainTargetValues;
return playable;
}
public ClipCaps clipCaps => ClipCaps.Extrapolation;
}
}