// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik // #if UNITY_EDITOR using System; using System.Collections.Generic; using UnityEngine; namespace Animancer.Editor.TransitionLibraries { /// https://kybernetik.com.au/animancer/api/Animancer.Editor.TransitionLibraries/TransitionLibraryEditorDataInternal public partial class TransitionLibraryEditorDataInternal { /************************************************************************************************************************/ [SerializeField] private List _TransitionGroups; /// [] The groups which transitions are organised in. public ref List TransitionGroups { get { _TransitionGroups ??= new(); return ref _TransitionGroups; } } /************************************************************************************************************************/ } /// [Editor-Only] /// A group of transitions for display organisation in the . /// /// https://kybernetik.com.au/animancer/api/Animancer.Editor.TransitionLibraries/TransitionGroup [Serializable] public class TransitionGroup : ICopyable, IEquatable { /************************************************************************************************************************/ #region Fields and Properties /************************************************************************************************************************/ [SerializeField] private string _Name; /// [] The display name of this group. public ref string Name => ref _Name; /************************************************************************************************************************/ [SerializeField] private int _Index; /// [] /// The display index of this group within the . /// public ref int Index => ref _Index; /************************************************************************************************************************/ [SerializeField] private bool _IsExpanded = true; /// [] Is this group currently showing its contents? public ref bool IsExpanded => ref _IsExpanded; /************************************************************************************************************************/ [SerializeField] private List _TransitionIndices; /// [] /// The indices of the transitions in the . /// public ref List TransitionIndices { get { _TransitionIndices ??= new(); return ref _TransitionIndices; } } /************************************************************************************************************************/ [NonSerialized] private List _Transitions; /// The transitions referenced by . /// This list is temporarily filled during GUI calls in the . public List Transitions => _Transitions ??= new(); /************************************************************************************************************************/ #endregion /************************************************************************************************************************/ #region Equality /************************************************************************************************************************/ /// Are all fields in this object equal to the equivalent in `obj`? public override bool Equals(object obj) => Equals(obj as TransitionGroup); /// Are all fields in this object equal to the equivalent fields in `other`? public bool Equals(TransitionGroup other) => other != null && _Name == other._Name && _Index == other._Index && _IsExpanded == other._IsExpanded && AnimancerUtilities.ContentsAreEqual(TransitionIndices, other.TransitionIndices); /// Are all fields in `a` equal to the equivalent fields in `b`? public static bool operator ==(TransitionGroup a, TransitionGroup b) => a is null ? b is null : a.Equals(b); /// Are any fields in `a` not equal to the equivalent fields in `b`? public static bool operator !=(TransitionGroup a, TransitionGroup b) => !(a == b); /************************************************************************************************************************/ /// Returns a hash code based on the values of this object's fields. public override int GetHashCode() => AnimancerUtilities.Hash(1598151553, _Name.GetHashCode(), _Index.GetHashCode(), _IsExpanded.GetHashCode(), TransitionIndices.GetHashCode()); /************************************************************************************************************************/ /// public void CopyFrom(TransitionGroup copyFrom, CloneContext context) { _Name = copyFrom._Name; _Index = copyFrom._Index; _IsExpanded = copyFrom._IsExpanded; TransitionIndices.Clear(); TransitionIndices.AddRange(copyFrom.TransitionIndices); } /************************************************************************************************************************/ /// public override string ToString() => $"{nameof(TransitionGroup)}({_Name}, {_Index}, {TransitionIndices.Count})"; /************************************************************************************************************************/ #endregion /************************************************************************************************************************/ } } #endif