Animation State of Controller not showing in Inspector when clicked
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.
Answer by desertGhost_ · Jun 02, 2020 at 04:24 PM
So this is an issue they are aware of:
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'"
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. =)
Where can I find the Animator file? I have been facing the same issue
Right click on the AnimatorController asset in your Unity project (in the Project tab of your editor) and select “Show in explorer”. A file explorer window will open the folder containing the asset, look for the “.controller” extension :)
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.
Answer by punk · Jul 27, 2020 at 06:59 AM
Thanks @NapsTeam Lifesaver! I updated your script to deal with Sub Statemachines and BlendTree's also
using UnityEditor;
using UnityEngine;
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;
if (curState.state.motion != null)
{
if (curState.state.motion.hideFlags != 0) curState.state.motion.hideFlags = (HideFlags)1;
}
}
foreach (UnityEditor.Animations.ChildAnimatorStateMachine curStateMachine in layer.stateMachine.stateMachines)
{
foreach (UnityEditor.Animations.ChildAnimatorState curState in curStateMachine.stateMachine.states)
{
if (curState.state.hideFlags != 0) curState.state.hideFlags = (HideFlags)1;
if (curState.state.motion != null)
{
if (curState.state.motion.hideFlags != 0) curState.state.motion.hideFlags = (HideFlags)1;
}
}
}
}
EditorUtility.SetDirty(ac);
}
}
@punk thanks man ! Now it's more then perfect :) Looking forward to a fix, which is not yet done even on 2020.1b
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;
}
}
where to make the change ?i see no script in animation
why the hell no body talks about how to use it, as if everyone here is some sort of Unity expert or something, guys there are newbies everywhere, pls help each other
this thing in the first line of the solution code that says: [$$anonymous$$enuItem("Tools/Animator States Unhide Fix")] is some sort of a new menu option on your Unity Editor the first part before slash is the menu in editor you have to look at, here is Tools, other solutions have Assets instead, the second part is the newly created option in that menu so you need to create an empty script in your scrips folder or where ever in your assets folder, then you need to copy paste the solution code in it, and then the option will be added to your EDITOR, after that you need to go to the Project tab in editor and go to your model and find the animator file that ends with .controller extension, click on it and select it, then go to the newly created option and choose it, then the script runs and activates the solution
Answer by NechyporukEvgen · Aug 06, 2020 at 10:45 AM
Multiple fixer:
using UnityEditor;
using UnityEngine;
public class AnimUnhideTool : ScriptableObject
{
[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)
{
UnityEditor.Animations.AnimatorController ac = o as UnityEditor.Animations.AnimatorController;
if (ac == null) continue;
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;
scnt++;
}
if (curState.state.motion != null)
{
if (curState.state.motion.hideFlags != 0) curState.state.motion.hideFlags = (HideFlags)1;
}
}
foreach (UnityEditor.Animations.ChildAnimatorStateMachine curStateMachine in layer.stateMachine.stateMachines)
{
foreach (UnityEditor.Animations.ChildAnimatorState curState in curStateMachine.stateMachine.states)
{
if (curState.state.hideFlags != 0)
{
curState.state.hideFlags = (HideFlags)1;
scnt++;
}
if (curState.state.motion != null)
{
if (curState.state.motion.hideFlags != 0) curState.state.motion.hideFlags = (HideFlags)1;
}
}
}
}
EditorUtility.SetDirty(ac);
}
Debug.Log("Fixing " + scnt + " states done!");
}
}
Answer by desertGhost_ · May 31, 2020 at 02:30 AM
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?
From what I have seen the individual animation states are probably corrupted. If I copy them inside the same controller, the copied version is also not visible. If I however import the same animation again from the model into the controller, it shows up normally. I'll file a bug report for this but the controllers have to probably be recreated in the end which is a little bit annoying. It's interesting though because I have played the scene with all animator controllers again and again and it seems that all data of the controllers still works because everything works as intended. Only once or twice did the scripts and animations not work when played. So it might just have to do with the editor itself. $$anonymous$$aybe something was changed from the old unity versions that can not be understood by the new versions of the editor.
That was my thinking so I started creating a new animator controller (there were somethings that I wanted to reorganize in $$anonymous$$e anyway). The first layer I created works fine, but interestingly the second layer I created began experiencing the issue after a while. I did recreate a simple repro project and submitted a bug report, but I have not heard back on whether they have been able to reproduce the bug yet.
Answer by reigota · Sep 02, 2020 at 08:03 PM
A bit more complete and recursive solution, based on previous answers:
using UnityEditor;
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)
{
UnityEditor.Animations.AnimatorController ac = o as UnityEditor.Animations.AnimatorController;
if (ac == null)
continue;
foreach (UnityEditor.Animations.AnimatorControllerLayer layer in ac.layers)
{
foreach (UnityEditor.Animations.ChildAnimatorState curState in layer.stateMachine.states)
{
scnt = FixState(scnt, curState);
}
scnt = FixStateMachines(scnt, layer.stateMachine.stateMachines);
}
EditorUtility.SetDirty(ac);
}
Debug.Log("Fixing " + scnt + " states done!");
}
private static int FixStateMachines(int scnt, UnityEditor.Animations.ChildAnimatorStateMachine[] stateMachines)
{
foreach (UnityEditor.Animations.ChildAnimatorStateMachine curStateMachine in stateMachines)
{
if (curStateMachine.stateMachine.hideFlags != (HideFlags)1)
{
curStateMachine.stateMachine.hideFlags = (HideFlags)1;
}
if (curStateMachine.stateMachine.stateMachines != null)
{
scnt = FixStateMachines(scnt, curStateMachine.stateMachine.stateMachines);
}
if (curStateMachine.stateMachine.entryTransitions != null)
{
foreach (UnityEditor.Animations.AnimatorTransition curTrans in curStateMachine.stateMachine.entryTransitions)
{
if (curTrans.hideFlags != (HideFlags)1)
{
curTrans.hideFlags = (HideFlags)1;
}
}
}
foreach (UnityEditor.Animations.ChildAnimatorState curState in curStateMachine.stateMachine.states)
{
scnt = FixState(scnt, curState);
}
}
return scnt;
}
private static int FixState(int scnt, UnityEditor.Animations.ChildAnimatorState curState)
{
if (curState.state.hideFlags != (HideFlags)1)
{
curState.state.hideFlags = (HideFlags)1;
scnt++;
}
if (curState.state.motion != null)
{
if (curState.state.motion.hideFlags != (HideFlags)1)
curState.state.motion.hideFlags = (HideFlags)1;
}
if (curState.state.transitions != null)
{
foreach (UnityEditor.Animations.AnimatorStateTransition curTrans in curState.state.transitions)
{
if (curTrans.hideFlags != (HideFlags)1)
{
curTrans.hideFlags = (HideFlags)1;
}
}
}
if (curState.state.behaviours != null)
{
foreach (StateMachineBehaviour behaviour in curState.state.behaviours)
{
if (behaviour.hideFlags != (HideFlags)1)
behaviour.hideFlags = (HideFlags)1;
}
}
return scnt;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612235705im_/https://answers.unity.com/themes/thub/images/avi.jpg)