How to Set State/StateMechine' postion in Controller by script
I trying to set a new position for state/stateMechine , but It doesn't work...... here is what I try to do And I don't know why...
void SetClipPosition(UnityEditor.Animations.AnimatorController ctrl)
{
foreach (UnityEditor.Animations.AnimatorControllerLayer layer in ctrl.layers)
{
int y = 0;
for (int i = 0; i <layer.stateMachine.states.Length; i++)
{
y = i*50;
layer.stateMachine.states[i].position = new Vector3(0, y, 0);
}
for (int i = 0; i <layer.stateMachine.stateMachines.Length; i++)
{
y = i*50;
layer.stateMachine.stateMachines[i].position = new Vector3(30, y, 0);
}
}
string ctrlpth = AssetDatabase.GetAssetPath(ctrl);
AssetDatabase.WriteImportSettingsIfDirty(ctrlpth);
}
Comment
I tried it same way and also doesn't work in Unity 2017 :-(.