// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2023 Kybernetik // using UnityEngine; namespace Animancer { /// /// https://kybernetik.com.au/animancer/api/Animancer/AnimancerTransitionAsset_1 [HelpURL(Strings.DocsURLs.APIDocumentation + "/" + nameof(AnimancerTransitionAsset) + "_1")] public class AnimancerTransitionAsset : AnimancerTransitionAssetBase where TTransition : ITransition { /************************************************************************************************************************/ [SerializeReference] private TTransition _Transition; /// [] /// The wrapped by this . /// /// /// WARNING: the holds the most recently played state, so /// if you are sharing this transition between multiple objects it will only remember one of them. /// Consider using an . /// /// You can use or /// to get or create the state for a /// specific object. /// public TTransition Transition { get { AssertTransition(); return _Transition; } set => _Transition = value; } /// Returns the wrapped by this . public override ITransition GetTransition() { AssertTransition(); return _Transition; } /************************************************************************************************************************/ /// Is the assigned (i.e. not null)? public bool HasTransition => _Transition != null; /************************************************************************************************************************/ /// [Assert-Conditional] Logs an error if the is null. [System.Diagnostics.Conditional(Strings.Assertions)] private void AssertTransition() { if (_Transition == null) Debug.LogError($"'{name}' {nameof(Transition)} is not assigned." + $" {nameof(HasTransition)} can be used to check without triggering this error.", this); } /************************************************************************************************************************/ #if UNITY_EDITOR /// [Editor-Only] /// Assigns a default to the field. /// protected virtual void Reset() { _Transition = Editor.TypeSelectionButton.CreateDefaultInstance(); } #endif /************************************************************************************************************************/ } }