Search Unity

Mecanim: Using new automatic settings?

Discussion in 'Animation' started by FeastSC2, Sep 8, 2017.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    When creating a new transition with Mecanim/Animator the automatic transition settings are set as such:



    I would like to make some of those settings be false or 0, I found the way to do that but I have to click on a button to clean up all the transitions in an Animator.
    Now I hope to take it a step further and change those settings as soon as I create the transition (it would be like having my personal defaults settings). Is there some kind of event that I can listen to that gets called on the creation of transitions in Mecanim?
     
    petey likes this.
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    For the moment, you can't setup your own defaults, or really mass-edit transitions (the multi-object inspector is already used to display a list of transitions when selecting multiple transitions between two states in the Animator Window).

    We have a team working on implementing defaults, but it's not ready yet.
    We also added copy paste of transition settings in 2017.2, which might help in the meantime.
    Otherwise, it's always possible to implement your own editor scripts to force settings on transitions
     
    FeastSC2 likes this.
  3. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    What do you mean by this?


    That's really nice that you plan on giving us defaults, it'd be really useful indeed.

    In the meantime, if someone's interested in setting all the transitions to something specific in an animator, you can use this code: (just have to drag and drop the animator in an EditorWindow then execute this code)
    Code (CSharp):
    1. private void CleanTransitions()
    2.     {
    3.         //var allAnimatorControllers = GameObject.FindObjectsOfType<AnimatorController>();
    4.         //foreach (var animController in allAnimatorControllers)
    5.         //{
    6.         //    // Do for all in the project
    7.         //}
    8.         if (AnimatorController) // private static AnimatorController AnimatorController;
    9.         {
    10.             for (int i = 0; i < AnimatorController.layers.Length; i++)
    11.             {
    12.                 var stateMachine = AnimatorController.layers[i].stateMachine;
    13.  
    14.                 if (stateMachine == null) return;
    15.  
    16.                 var states = stateMachine.states;
    17.  
    18.                 List<AnimatorStateTransition> allTransitions = new List<AnimatorStateTransition>();
    19.                 foreach (var state in states)
    20.                 {
    21.                     allTransitions.AddRange(state.state.transitions);
    22.                 }
    23.  
    24.                 foreach (var transition in allTransitions)
    25.                 {
    26.                     transition.duration = 0;
    27.                     transition.exitTime = 1;
    28.  
    29.                     //transition.canTransitionToSelf = false;
    30.                     //transition.hasExitTime = false;
    31.                     //transition.hasFixedDuration = true;
    32.                     //transition.interruptionSource = TransitionInterruptionSource.None;
    33.                     //transition.offset = 0;
    34.                 }
    35.             }
    36.         }
    37.     }
     
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I added a right click, contextual menu in the transition inspector to copy and paste transition settings and/or conditions.

    You right click a transition in the list of transitions, select copy.
    Then you right click another transition, and select "Paste Settings", "Paste Conditions" or "Paste Both".
     
    theANMATOR2b and FeastSC2 like this.
  5. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Any news on the default settings for the Animator?