Hyluss

[Unity] Get length of animation

Sep 29th, 2017
295
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.34 KB | None | 0 0
  1. Animator animator = GetComponent<Animator>();
  2. float time;
  3. RuntimeAnimatorController ac = animator.runtimeAnimatorController;    //Get Animator controller
  4. print (ac.animationClips[0].length);
  5.  
  6.  
  7. OR
  8.  
  9. Animator animator;
  10. AnimatorClipInfo[] clipInfo = animator.GetCurrentAnimatorClipInfo(0);
  11. float animationLength = clipInfo[0].clip.length;
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment