I recently updated my Unity version to 2019.3.15f1. I opened a project which was created in the 2017 version of unity. My problem is that after upgrading to the new version, when I click on a state in the animator controller the state sometimes does not show in the inspector. But that’s not all. Some states do show in the inspector when clicked some do not.
For example I had a script on a statemachine that handles multiple animations. The script also does not show when I click on the statemachine.
I don’t know if I am missing something obvious, or if it actually is a problem created by switching the version.
I also am having this issue in my project after upgrading to 2019.3.15f1. I think this could be a bug. I made a copy of my project and tried opening it in 2020.1.0b10 with the same result. I just hope that the animator controllers weren't corrupted by 2019.3.15f1. Has anyone filed a bug report?
This "hack" solved it! Thanks so much. We should all VOTE on that issue tracker and submit a bug report Via Unity editor.. so this can be fixed properly. =)
All flags were already at 1. All my animations work. What breaks when I add or edit an animation is the movement code! It stops moving left or right based on right or left arrow! EVERYTIME! No matter what I add or how I edit an animation, movement code breaks. If I delete the animation state that was added or edited, it starts working again. Further, if I add or edit an animation immediately, the same thing happens: movement code stops working.
Thanks @NapsTeam and @punk - I had hidden transitions too, so I modified the script to unhide those. Just added the following inside both foreach curState loops: foreach (UnityEditor.Animations.AnimatorStateTransition curTrans in curState.state.transitions) { if (curTrans.hideFlags != 0) { Debug.Log("...fixing transition"); curTrans.hideFlags = (HideFlags)1; } }
I also am having this issue in my project after upgrading to 2019.3.15f1. I think this could be a bug. I made a copy of my project and tried opening it in 2020.1.0b10 with the same result. I just hope that the animator controllers weren’t corrupted by 2019.3.15f1. Has anyone filed a bug report?
reigota answer that Includes animator transitions:
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
public class AnimUnhideTool
{
[MenuItem("Tools/Animator States Unhide Fix")]
private static void Fix()
{
if (Selection.objects.Length < 1)
throw new UnityException("Select animator controller(s) before try fix it!");
int scnt = 0;
foreach (Object o in Selection.objects)
{
AnimatorController ac = o as AnimatorController;
if (ac == null)
continue;
foreach (AnimatorControllerLayer layer in ac.layers)
{
foreach (ChildAnimatorState curState in layer.stateMachine.states)
{
scnt = FixState(scnt, curState);
}
scnt = FixStateMachines(scnt, layer.stateMachine, layer.stateMachine.stateMachines);
}
EditorUtility.SetDirty(ac);
}
Debug.Log("Fixing " + scnt + " states done!");
}
private static int FixStateMachines(int scnt, AnimatorStateMachine parent, ChildAnimatorStateMachine[] stateMachines)
{
foreach (ChildAnimatorStateMachine curStateMachine in stateMachines)
{
foreach (var trans in parent.GetStateMachineTransitions(curStateMachine.stateMachine))
{
trans.hideFlags = (HideFlags)1;
scnt++;
}
if (curStateMachine.stateMachine.hideFlags != (HideFlags)1)
{
curStateMachine.stateMachine.hideFlags = (HideFlags)1;
}
if (curStateMachine.stateMachine.stateMachines != null)
{
scnt = FixStateMachines(scnt, curStateMachine.stateMachine, curStateMachine.stateMachine.stateMachines);
}
if (curStateMachine.stateMachine.entryTransitions != null)
{
foreach (AnimatorTransition curTrans in curStateMachine.stateMachine.entryTransitions)
{
curTrans.hideFlags = (HideFlags)1;
}
}
foreach (ChildAnimatorState curState in curStateMachine.stateMachine.states)
{
scnt = FixState(scnt, curState);
}
}
return scnt;
}
private static int FixState(int scnt, ChildAnimatorState curState)
{
if (curState.state.hideFlags != (HideFlags)1)
{
curState.state.hideFlags = (HideFlags)1;
scnt++;
}
if (curState.state.motion != null)
{
curState.state.motion.hideFlags = (HideFlags)1;
}
if (curState.state.transitions != null)
{
foreach (AnimatorStateTransition curTrans in curState.state.transitions)
{
curTrans.hideFlags = (HideFlags)1;
}
}
if (curState.state.behaviours != null)
{
foreach (StateMachineBehaviour behaviour in curState.state.behaviours)
{
behaviour.hideFlags = (HideFlags)1;
}
}
return scnt;
}
}
For anyone Googling this later, I used this script and it resolved my issue. I had a broken Opsive Animator Controller (Ever try to rebuild one of those?) and this has fixed the issue for me. No side effects yet, but having backups is a good idea so you don't make the problem worse. @RShiftStudios thanks for providing this version! And of course thanks to the previous folk that initially came up with a fix.
I’m having the same problem. All the duplicate states in the animation controller have blank inspectors. This affects all the duplicated states that were created before the update as well.
You can try this script we used as workaround for now
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using UnityEditor;
using UnityEditor.Animations;
public class AnimUnhideTool : ScriptableObject
{
[MenuItem("Assets/Unhide Fix")]
private static void unhide()
{
UnityEditor.Animations.AnimatorController ac = Selection.activeObject as UnityEditor.Animations.AnimatorController;
foreach (UnityEditor.Animations.AnimatorControllerLayer layer in ac.layers)
{
foreach (UnityEditor.Animations.ChildAnimatorState curState in layer.stateMachine.states)
{
if (curState.state.hideFlags!=0) curState.state.hideFlags = (HideFlags)1;
}
}
EditorUtility.SetDirty(ac);
}
}
The above scripts do not fix the problem if you are using duplicate statemachinebehavior scripts/components on your animator states. Any duplicate statemachinebehaviors on your animator states remain hidden from view after using the AnimUnHideTool scripts. And the stateMachineBehaviors do not run if they are hidden in the inspector. Additionally, you cannot add duplicates of the same statemachinebehavior script to a state. I’m using Unity 2020.1.12 and 2020.1.13.
I also am having this issue in my project after upgrading to 2019.3.15f1. I think this could be a bug. I made a copy of my project and tried opening it in 2020.1.0b10 with the same result. I just hope that the animator controllers weren't corrupted by 2019.3.15f1. Has anyone filed a bug report?
– desertGhostSo this is an issue they are aware of: https://issuetracker.unity3d.com/issues/inspector-not-displaying-state-and-transition-properties-once-duplicated The work around is to "Open the Animator file in a Text Editor and change the 'm_ObjectHideFlags' properties for the affected states from '3' to '1'"
– desertGhost