// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik // using System.Collections.Generic; using UnityEngine; namespace Animancer.TransitionLibraries { /// [Pro-Only] /// A which serializes a /// and creates a from it at runtime. /// /// /// Documentation: /// /// Transition Libraries /// /// https://kybernetik.com.au/animancer/api/Animancer.TransitionLibraries/TransitionLibraryAsset [CreateAssetMenu( menuName = Strings.MenuPrefix + "Transition Library", order = Strings.AssetMenuOrder + 0)] [AnimancerHelpUrl(typeof(TransitionLibraryAsset))] public class TransitionLibraryAsset : ScriptableObject, IAnimationClipSource { /************************************************************************************************************************/ [SerializeField] private TransitionLibraryDefinition _Definition; /// [] /// The serialized data which will be used to initialize the at runtime. /// /// /// If you modify the contents of this reference, either re-assign this property /// or call to apply any changes to the . /// public TransitionLibraryDefinition Definition { get => _Definition; set { _Definition = value ?? new(); OnDefinitionModified(); } } #if UNITY_EDITOR /// [Editor-Only] [Internal] /// The name of the field which stores the . /// internal const string DefinitionField = nameof(_Definition); #endif /************************************************************************************************************************/ /// The runtime created from the . public TransitionLibrary Library { get; private set; } /************************************************************************************************************************/ /// Initializes the . protected virtual void OnEnable() { _Definition ??= new(); Library = new(); Library.Initialize(_Definition); } /************************************************************************************************************************/ /// /// Adds the contents of the /// to the if it was already initialized. /// /// /// Call this after modifying the contents of the /// to ensure that the reflects any changes. /// /// Note that this doesn't remove anything from the , /// it only adds or replaces values. /// public void OnDefinitionModified() { Library.Initialize(_Definition); } /************************************************************************************************************************/ /// Gathers all the animations in the and . public void GetAnimationClips(List results) { results.GatherFromSource(_Definition); results.GatherFromSource(Library); } /************************************************************************************************************************/ } }