hecomi / uLipSync

MFCC-based LipSync plug-in for Unity using Job System and Burst Compiler
https://tips.hecomi.com/entry/2022/01/30/152519
MIT License
1.07k stars 128 forks source link

uLipsyncAnimator #38

Closed liudger closed 1 year ago

liudger commented 1 year ago

When selecting asset on disk with ulipsyncAnimator this error appear in console and interface is broken.

Animator is not playing an AnimatorController
UnityEngine.StackTraceUtility:ExtractStackTrace ()
uLipSync.uLipSyncAnimatorEditor:DrawParameterListItem (UnityEngine.Rect,int) (at Assets/talespin-core/Plugins/uLipSync/Editor/uLipSyncAnimatorEditor.cs:147)
uLipSync.uLipSyncAnimatorEditor:<DrawAnimatorReorderableList>b__6_1 (UnityEngine.Rect,int,bool,bool) (at Assets/talespin-core/Plugins/uLipSync/Editor/uLipSyncAnimatorEditor.cs:118)
UnityEditorInternal.ReorderableList:DoListElements (UnityEngine.Rect,UnityEngine.Rect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:946)
UnityEditorInternal.ReorderableList:DoLayoutList () (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:723)
uLipSync.uLipSyncAnimatorEditor:DrawAnimatorReorderableList () (at Assets/talespin-core/Plugins/uLipSync/Editor/uLipSyncAnimatorEditor.cs:130)
uLipSync.uLipSyncAnimatorEditor:OnInspectorGUI () (at Assets/talespin-core/Plugins/uLipSync/Editor/uLipSyncAnimatorEditor.cs:49)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

image

To prevent this error I would suggest checking if the animator is enabled? Or is there another way to fix this when still able to see and edit the parameters?

if (EditorUtil.Foldout("Animator Controller Parameters", true))
        {
            ++EditorGUI.indentLevel;
            if (anim.animator != null && anim.animator.isActiveAndEnabled)
            {
                DrawAnimatorReorderableList();
            }
            else
            {
                EditorGUILayout.HelpBox("Animator is not available! To edit parameters open the prefab or have game object in scene.", MessageType.Warning);
            }
            --EditorGUI.indentLevel;
            EditorGUILayout.Separator();
        }
liudger commented 1 year ago

I think I found another issue. The parameters are not hashed when playback runtime starts?

My previous code was a bit different. We get the config from json file and set in editor not at runtime (our workflow requires fully configured characters as package uploaded to the cloud). So the hash of the parameters are still null. I had this on Awake:

void Awake()
        {
            foreach (AnimatorInfo par in parameters)
            {
                par.nameHash = Animator.StringToHash(par.name);
            }
        }
liudger commented 1 year ago

I found another issue 😄 . It's not a bit issue but the issue was that the smooth was causing really small values being pushed to the animator. And this could cause issues image

I'll create a pull request with the fix