- Home /
AnimatorControllers created on disk via script not retaining new layer information. [Unity 5.6]
https://docs.unity3d.com/ScriptReference/Animations.AnimatorController.html
Following that model, but adding layers rather than messing with base layer.
Here's the gist:
 AnimatorController animCtrl = AnimatorController.CreateAnimatorControllerAtPath(someValidPath);           
 List<AnimatorControllerLayer> layers = new List<AnimatorControllerLayer>(animCtrl.layers);
 loop{
     layer = new AnimatorControllerLayer();
     sm = new AnimatorStateMachine();    
     sm.AddState("default");
     layer.defaultWeight = 1.0f;
     layer.name = layerName;
     layer.stateMachine = sm;
     layers.Add(layer);
 }
 
 layers.Sort(new SortByName());         
 animCtrl.layers = layers.ToArray();
 AssetDatabase.SaveAssets();
When I look at the generated controllers in the Animator window, everything looks right. When I change scenes, only the controller currently open in the Animator window is retained. All other controllers still contain the layers in the correct order, and any parameters I've added (not shown), but there's no 'grid' shown when you select a layer.
The base layer is fine, however. I assume this grid is the visualization of the layer.stateMachine which is for some reason not saving to disk.
What's going on here? Is there a workaround, am I not calling something to force those layer state machines to save?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                