Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Animator state name strings in development builds?

Discussion in 'Unity 5 Pre-order Beta' started by chrismarch, Nov 20, 2014.

  1. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
    We frequently need to debug our non-trivial Mecanim state machines at runtime in development builds, and one of the most useful tools is to see the name of the state (ideally, the full path). Up until Unity 5, we'd been using a script plugin that built up a hashtable using the naughty UnityEditorInternal API so that we could have this info at runtime in our development builds. As you might guess, the UnityEditorInternal API has changed, and we really don't want to be using it anyways.

    For some reason, I was expecting Unity 5 to bring something like: "Animator.HashToString" or even "string AnimatorStateInfo.name," at least in development builds. Am I missing an existing way in beta 13 to get the currently playing state name strings at runtime, without mucking around again with UnityEditorInternal at build time? Is a feature like this planned for 5.0?
     
  2. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
    found it:

    Code (CSharp):
    1. namespace UnityEditorInternal
    2. {
    3.     [Obsolete("StateMachine is obsolete. Use UnityEditor.Animations.AnimatorStateMachine instead (UnityUpgradable).", true)]
    4.     public class StateMachine : UnityEngine.Object
    5.     {
    6.         public StateMachine();
    7.     }
    8. }
    9.