summaryrefslogtreecommitdiff
path: root/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Animation/AnimationNodes.cs
blob: 28d0efd90ef7c85d8dd839f4362ca25f27bfa5e1 (plain)
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
using UnityEngine;

namespace UnityEngine.Graphs.LogicGraph
{
	public partial class AnimationNodes
	{
		[Logic(typeof(Animation))]
		[return: Title("Animation State")]
		public static AnimationState GetAnimationState (Animation self, [Setting] string animationStateName)
		{
			return self[animationStateName];
		}

		[Logic(typeof(Animation))]
		[return: Title("Animation State")]
		public static AnimationState PlayAnimation (Animation self, [Setting] string animationName, [Setting] bool crossfade, [Setting] float fadeLength, [Setting] PlayMode playMode)
		{
			AnimationState animationState = self[animationName == "" ? self.clip.name : animationName];

			if (crossfade)
				self.CrossFade (animationState.name, fadeLength, playMode);
			else
				self.Play (animationState.name, playMode);

			return animationState;
		}

		[Logic(typeof(Animation))]
		[return: Title("Animation State")]
		public static AnimationState PlayQueuedAnimation (Animation self, [Setting] string animationName, [Setting] bool crossfade, [Setting] float fadeLength, [Setting] QueueMode queueMode, [Setting] PlayMode playMode)
		{
			if (animationName == "")
				animationName = self.clip.name;

			var animationState = crossfade ? 
				self.CrossFadeQueued (animationName, fadeLength, queueMode, playMode) : 
				self.PlayQueued (animationName, queueMode, playMode);

			return animationState;
		}

		[Logic(typeof(Animation))]
		public static void StopAnimation (Animation self, [Setting] string animationName)
		{
			if (animationName == "")
				self.Stop();
			else
				self.Stop(animationName);
		}

		[Logic (typeof (Animation))]
		public static void SampleAnimation (Animation self)
		{
			self.Sample ();
		}

		[Logic(typeof(Animation))]
		public static void StopAnimationState (Animation self, AnimationState animationState)
		{
			self.Stop(animationState.name);
		}

		[Logic(typeof(Animation))]
		public static void BlendAnimationState (Animation self, AnimationState animationState, float targetWeight, [Setting] float fadeLength)
		{
			self.Blend (animationState.name, targetWeight, fadeLength);
		}

		[Logic(typeof(Animation))]
		public static void SyncAnimationLayer (Animation self, int layer)
		{
			self.SyncLayer (layer);
		}
	}
}