Search Unity

Sample Mecanim Animations in Editor

Discussion in 'Animation' started by akelsey, Aug 18, 2014.

  1. akelsey

    akelsey

    Joined:
    Nov 20, 2012
    Posts:
    12
    Hey all, quick question:

    Is there a script function that allows the playing of animations inside the editor outside of play mode?

    In the legacy system this is available, but i have yet to stumble across the equivalent in mecanim.

    I know about the [Execute in editor mode] option, but what script call for mecanim states goes along with that?

    Thanks in advance!
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi akelsey,

    Here a script that show you how to achieve this.

    Best regards,
    Sonny
     

    Attached Files:

    forestrf, icetec and IgorAherne like this.
  3. akelsey

    akelsey

    Joined:
    Nov 20, 2012
    Posts:
    12
    Awesome! Thanks!
     
  4. akelsey

    akelsey

    Joined:
    Nov 20, 2012
    Posts:
    12
    Does this work on optimized gameobjects?

    I am getting an error:
    pose.m_Count == transformCount
    UnityEditor.AnimationMode:SampleAnimationClip(GameObject, AnimationClip, Single)
     
  5. akelsey

    akelsey

    Joined:
    Nov 20, 2012
    Posts:
    12
    Is there a way to deoptimize the transform hierarchy in script?

    I would just want to do it to the scene object as I am previewing it. Doesnt look like the animation window supports optimized gameobjects animation either...
     
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
  7. akelsey

    akelsey

    Joined:
    Nov 20, 2012
    Posts:
    12
    We are using 4.3, it doesnt look like this option is available yet.

    Which version did this come online?
     
  8. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    In 4.3, the function was in another namespace

    UnityEditor.GameObjectUtility.OptimizeTransformHierarchy(GameObject go)
     
  9. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @Mecanim.Dev is the script working in 4.6.2? i got flickering animation when the animate button are active
     
  10. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    I don't know rea, I didn't test this script since 4.3
     
  11. xCyborg

    xCyborg

    Joined:
    Oct 4, 2010
    Posts:
    633
    Why dont you support sampling animation and preferably the whole state machine in editor natively like the old animation,
     
  12. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    You can, setup all your controller's input parameter and call manually animator.Update(deltaTime).

    There is even some user doing IK in the editor with the Animator built in IK.
    http://forum.unity3d.com/threads/set-up-ik-in-editor.332035/#post-2155040