From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- .../LogicNodeLibrary/Animation/AnimationNodes.cs | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Animation/AnimationNodes.cs (limited to 'Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Animation/AnimationNodes.cs') diff --git a/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Animation/AnimationNodes.cs b/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Animation/AnimationNodes.cs new file mode 100644 index 0000000..28d0efd --- /dev/null +++ b/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Animation/AnimationNodes.cs @@ -0,0 +1,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); + } + } +} + -- cgit v1.1-26-g67d0