Unity-AnimatorTransitionCopier
Unity-AnimatorTransitionCopier copied to clipboard
Add Feature to Copy StateMechineBehavior
if I just copy and Paste the State in the animator the scripts in the State are somehow linked when i change a value the pervious state script value also Changed.
I didn't get it. You are copying and pasting the state, which is Unity's built-in feature not the purpose of this repo. This repo is only used to copy the transition of states.
by the way I have created this function
void ShowAnimatorStateDublicator()
{
GUILayout.BeginHorizontal();
var selectedStates = Selection.GetFiltered<AnimatorState>(SelectionMode.Editable);
if (selectedStates != null && selectedStates.Length > 0)
{
if (GUILayout.Button("CopyBehaviors"))
{
Debug.Log(Selection.activeObject);
stateBehaviors = selectedStates[0].behaviours;
}
if (stateBehaviors != null && stateBehaviors.Length > 0)
{
if (GUILayout.Button("PasteBehaviors"))
{
foreach (var selectedState in selectedStates)
{
Undo.RecordObject(selectedState, "Paste Behaviors");
EditorUtility.SetDirty(selectedState);
foreach (var smb in stateBehaviors)
{
Debug.Log("Adding: " + smb.GetType());
var newSmb = selectedState.AddStateMachineBehaviour(smb.GetType());
EditorUtility.CopySerialized(smb, newSmb);
}
EditorUtility.SetDirty(selectedState);
}
}
}
}
GUILayout.EndHorizontal();
}