diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Animation/AnimationStateNetworkProvider.cpp |
Diffstat (limited to 'Runtime/Animation/AnimationStateNetworkProvider.cpp')
-rw-r--r-- | Runtime/Animation/AnimationStateNetworkProvider.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Runtime/Animation/AnimationStateNetworkProvider.cpp b/Runtime/Animation/AnimationStateNetworkProvider.cpp new file mode 100644 index 0000000..3393736 --- /dev/null +++ b/Runtime/Animation/AnimationStateNetworkProvider.cpp @@ -0,0 +1,51 @@ +#include "UnityPrefix.h" +#include "AnimationStateNetworkProvider.h" +#include "Runtime/Interfaces/IAnimationStateNetworkProvider.h" +#include "AnimationState.h" +#include "Animation.h" + +class AnimationStateNetworkProvider : public IAnimationStateNetworkProvider +{ +public: + + virtual int GetNetworkAnimationStateCount (Animation& animation) + { + return animation.GetAnimationStateCount(); + } + + virtual void GetNetworkAnimationState (Animation& animation, AnimationStateForNetwork* output, int count) + { + for (int i=0;i<count;i++) + { + AnimationState& state = animation.GetAnimationStateAtIndex(i); + + output[i].enabled = state.GetEnabled (); + output[i].weight = state.GetWeight (); + output[i].time = state.GetTime (); + } + } + + virtual void SetNetworkAnimationState (Animation& animation, const AnimationStateForNetwork* serialize, int count) + { + for (int i=0;i<count;i++) + { + AnimationState& state = animation.GetAnimationStateAtIndex(i); + + state.SetEnabled (serialize[i].enabled); + state.SetWeight (serialize[i].weight); + state.SetTime (serialize[i].time); + } + } +}; + +void InitializeAnimationStateNetworkProvider () +{ + SetIAnimationStateNetworkProvider(UNITY_NEW_AS_ROOT(AnimationStateNetworkProvider, kMemPhysics, "AnimationStateNetworkInterface", "")); +} + +void CleanupAnimationStateNetworkProvider () +{ + AnimationStateNetworkProvider* module = reinterpret_cast<AnimationStateNetworkProvider*> (GetIAnimationStateNetworkProvider ()); + UNITY_DELETE(module, kMemPhysics); + SetIAnimationStateNetworkProvider(NULL); +}
\ No newline at end of file |