/************************************************************************************************************************/ /// <summary>Calls <see cref="ITransition.CreateState"/> and <see cref="ITransition.Apply"/>.</summary> public static AnimancerState CreateStateAndApply(this ITransition transition, AnimancerPlayable root = null) { var state = transition.CreateState(); state.SetRoot(root); transition.Apply(state); return(state); }
/// <summary> /// Returns the state registered with the `transition`s <see cref="IHasKey.Key"/> if there is one. Otherwise /// this method uses <see cref="ITransition.CreateState"/> to create a new one and registers it with /// that key before returning it. /// </summary> public AnimancerState GetOrCreate(ITransition transition) { var key = transition.Key; if (!TryGet(key, out var state)) { state = transition.CreateState(); state.SetRoot(Root); Register(key, state); } return(state); }
/// <summary> /// Returns the state registered with the <see cref="IHasKey.Key"/> if there is one. Otherwise /// this method uses <see cref="ITransition.CreateState"/> to create a new one and registers it with /// that key before returning it. /// </summary> public AnimancerState GetOrCreateState(ITransition transition) { var key = transition.Key; AnimancerState state; if (!Root.States.TryGet(key, out state)) { state = transition.CreateState(this); Root.States.Register(key, state); } return(state); }
/// <summary> /// Returns the state registered with the `transition`s <see cref="IHasKey.Key"/> if there is one. Otherwise /// this method uses <see cref="ITransition.CreateState"/> to create a new one and registers it with /// that key before returning it. /// </summary> public AnimancerState GetOrCreate(ITransition transition) { var key = transition.Key; AnimancerState state; if (!States.TryGetValue(key, out state)) { state = transition.CreateState(Root.Layers[0]); Root.States.Register(key, state); } return(state); }