From 05b3d80c18ff17cb279d3b80cf9e27ac4f7acfb8 Mon Sep 17 00:00:00 2001 From: Acid Bubbles Date: Thu, 15 Sep 2022 23:50:51 -0400 Subject: [PATCH] Allow grouping controls, triggers and morphs --- .../Animatables/Base/AnimationTargetBase.cs | 1 + .../Animatables/Base/IAtomAnimationTarget.cs | 1 + .../Animations/AtomAnimationClip.cs | 22 ++++++------------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/AtomAnimations/Animatables/Base/AnimationTargetBase.cs b/src/AtomAnimations/Animatables/Base/AnimationTargetBase.cs index a4236b25..961a0b2c 100644 --- a/src/AtomAnimations/Animatables/Base/AnimationTargetBase.cs +++ b/src/AtomAnimations/Animatables/Base/AnimationTargetBase.cs @@ -5,6 +5,7 @@ namespace VamTimeline { public abstract class AnimationTargetBase : IDisposable where TAnimatableRef : AnimatableRefBase { + public AnimatableRefBase animatableRefBase => animatableRef; public TAnimatableRef animatableRef { get; } public UnityEvent onAnimationKeyframesDirty { get; } = new UnityEvent(); public UnityEvent onAnimationKeyframesRebuilt { get; } = new UnityEvent(); diff --git a/src/AtomAnimations/Animatables/Base/IAtomAnimationTarget.cs b/src/AtomAnimations/Animatables/Base/IAtomAnimationTarget.cs index 00cc6854..481dfa04 100644 --- a/src/AtomAnimations/Animatables/Base/IAtomAnimationTarget.cs +++ b/src/AtomAnimations/Animatables/Base/IAtomAnimationTarget.cs @@ -13,6 +13,7 @@ public interface IAtomAnimationTarget : IDisposable bool collapsed { get; set; } string group { get; set; } IAtomAnimationClip clip { get; set; } + AnimatableRefBase animatableRefBase { get; } void Validate(float animationLength); diff --git a/src/AtomAnimations/Animations/AtomAnimationClip.cs b/src/AtomAnimations/Animations/AtomAnimationClip.cs index 03237358..b1c24932 100644 --- a/src/AtomAnimations/Animations/AtomAnimationClip.cs +++ b/src/AtomAnimations/Animations/AtomAnimationClip.cs @@ -614,21 +614,13 @@ public void DirtyAll() public IEnumerable GetTargetGroups() { - yield return targetTriggers; - foreach (var group in targetControllers.GroupBy(t => t.group ?? t.animatableRef.groupKey)) - { - var first = group.First(); - yield return new AtomAnimationTargetsList(group) { label = first.group ?? first.animatableRef.groupLabel }; - } - foreach (var target in targetFloatParams) - { - target.animatableRef.EnsureAvailable(); - } - foreach (var group in targetFloatParams.GroupBy(t => t.group ?? t.animatableRef.groupKey)) - { - var first = group.First(); - yield return new AtomAnimationTargetsList(group) { label = first.group ?? first.animatableRef.groupLabel }; - } + return GetAllTargets() + .GroupBy(t => t.group ?? t.animatableRefBase.groupKey) + .Select(group => + { + var first = group.First(); + return (IAtomAnimationTargetsList) new AtomAnimationTargetsList(group) { label = first.group ?? first.animatableRefBase.groupLabel }; + }); } public void Validate()