Hi there, I’m building tools to automate creation of complex Animators and would like to be able to remove StateMachineBehaviours on states via script.
I expected that since there is a AddStateMachineBehaviour, there would be a RemoveStateMachineBehaviour, but this does not exist!
Next I tried to get all of the Behaviours on the Animator and call DestroyImmediate on them individually. GetBehaviours works, but DestroyImmediate doesn’t appear to do anything.
CustomStateBehaviour[] customStateBehaviour = myAnimator.GetBehaviours< CustomStateBehaviour>();
for (int s = 0; s < customStateBehaviour.Length; s++){
DestroyImmediate(customStateBehaviour~~);~~
}
I also tried putting a Destroy function inside the state machine behaviour and calling that instead of DestroyImmediate.
public void DestroySelf(){
DestroyImmediate(this);
}
This doesn’t work either. So how exactly can I destroy many StateMachineBehaviours in an Animator controller via Editor code?