-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AnimationsManager): Composite Animation.
The animations manager composite animation now exists
- Loading branch information
Showing
28 changed files
with
1,880 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!114 &11400000 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 0} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 8bed12526f9ecb043ba63c51bdace746, type: 3} | ||
m_Name: Composite_Test | ||
m_EditorClassIdentifier: | ||
_animationName: Composite_Test | ||
_fps: 8 | ||
_antecipationCycle: | ||
_animation: {fileID: 11400000} | ||
_frames: | ||
- _sprite: {fileID: 591964735, guid: 6a622a616b2d0204b8c9a9d1a19503c2, type: 3} | ||
_id: | ||
_identifiable: 1 | ||
_coreCycle: | ||
_animation: {fileID: 11400000} | ||
_frames: | ||
- _sprite: {fileID: 786707139, guid: 6a622a616b2d0204b8c9a9d1a19503c2, type: 3} | ||
_id: | ||
- _sprite: {fileID: -694870178, guid: 6a622a616b2d0204b8c9a9d1a19503c2, type: 3} | ||
_id: | ||
- _sprite: {fileID: 1868516302, guid: 6a622a616b2d0204b8c9a9d1a19503c2, type: 3} | ||
_id: | ||
_identifiable: 1 | ||
_recoveryCycle: | ||
_animation: {fileID: 11400000} | ||
_frames: | ||
- _sprite: {fileID: 1883112409, guid: 6a622a616b2d0204b8c9a9d1a19503c2, type: 3} | ||
_id: | ||
- _sprite: {fileID: -538822814, guid: 6a622a616b2d0204b8c9a9d1a19503c2, type: 3} | ||
_id: | ||
- _sprite: {fileID: -1684204194, guid: 6a622a616b2d0204b8c9a9d1a19503c2, type: 3} | ||
_id: | ||
_identifiable: 1 | ||
_loopableCore: 1 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
Assets/SpriteAnimations/Editor/Scripts/AnimationViews/SpriteAnimationViewComposite.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace SpriteAnimations.Editor | ||
{ | ||
public class SpriteAnimationViewComposite : SpriteAnimationView | ||
{ | ||
#region Fields | ||
|
||
private Toggle _loopableCoreField; | ||
private CycleElement _cycleElement; | ||
private SpriteAnimationComposite _compositeSpriteAnimation; | ||
private AnimationPreviewElement _animationPreview; | ||
private Cycle _currentCycle; | ||
private List<Button> _tabButtons; | ||
|
||
#endregion | ||
|
||
#region Getters | ||
|
||
public override AnimationType AnimationType => AnimationType.Composite; | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
public SpriteAnimationViewComposite() | ||
{ | ||
VisualTreeAsset tree = Resources.Load<VisualTreeAsset>("UI Documents/Animations Views/AnimationViewComposite"); | ||
TemplateContainer template = tree.CloneTree(); | ||
template.style.flexGrow = 1; | ||
|
||
_loopableCoreField = template.Q<Toggle>("loopable-core-field"); | ||
_loopableCoreField.RegisterValueChangedCallback(OnLoopableValueChanges); | ||
|
||
VisualElement animationPreviewContainer = template.Q<VisualElement>("animation-preview-container"); | ||
animationPreviewContainer.Clear(); | ||
_animationPreview = new AnimationPreviewElement(); | ||
animationPreviewContainer.Add(_animationPreview); | ||
|
||
VisualElement cycleContainer = template.Q<VisualElement>("cycle-view"); | ||
|
||
_tabButtons = template.Query<Button>(className: "tab-button").ToList(); | ||
|
||
_tabButtons.ForEach(tabButton => | ||
{ | ||
tabButton.clicked += () => OnCycleButtonClicked(tabButton); | ||
}); | ||
|
||
_cycleElement = new CycleElement(); | ||
cycleContainer.Add(_cycleElement); | ||
|
||
_contentContainer.Add(template); | ||
} | ||
|
||
#endregion | ||
|
||
#region Initializing | ||
|
||
public override void Initialize(SpriteAnimation animation) | ||
{ | ||
base.Initialize(animation); | ||
_compositeSpriteAnimation = animation as SpriteAnimationComposite; | ||
_loopableCoreField.value = _compositeSpriteAnimation.IsLoopableCore; | ||
InitializeCycle(_compositeSpriteAnimation.AntecipationCycle); | ||
|
||
foreach (Button button in _tabButtons) | ||
{ | ||
if (button.viewDataKey != "antecipation") return; | ||
button.AddToClassList("active"); | ||
break; | ||
} | ||
|
||
_animationPreview.Initialize(this, this, _cycleElement, _viewZoomSlider); | ||
} | ||
|
||
public override void Dismiss() | ||
{ | ||
base.Dismiss(); | ||
_compositeSpriteAnimation = null; | ||
_cycleElement?.Dismiss(); | ||
} | ||
|
||
#endregion | ||
|
||
#region Cycles | ||
|
||
private void InitializeCycle(Cycle cycle) | ||
{ | ||
_cycleElement?.Dismiss(); | ||
_currentCycle = cycle; | ||
_cycleElement.Initialize(cycle, this); // Must be initialized before the preview | ||
} | ||
|
||
private void EvaluateCycle(string cycleName) | ||
{ | ||
switch (cycleName) | ||
{ | ||
case "antecipation": | ||
InitializeCycle(_compositeSpriteAnimation.AntecipationCycle); | ||
break; | ||
case "core": | ||
InitializeCycle(_compositeSpriteAnimation.CoreCycle); | ||
break; | ||
case "recovery": | ||
InitializeCycle(_compositeSpriteAnimation.RecoveryCycle); | ||
break; | ||
default: | ||
InitializeCycle(_compositeSpriteAnimation.AntecipationCycle); | ||
break; | ||
} | ||
} | ||
|
||
private void OnCycleButtonClicked(Button button) | ||
{ | ||
_tabButtons.ForEach(tabButton => tabButton.RemoveFromClassList("active")); | ||
button.AddToClassList("active"); | ||
EvaluateCycle(button.viewDataKey); | ||
} | ||
|
||
#endregion | ||
|
||
#region Loopable | ||
|
||
private void OnLoopableValueChanges(ChangeEvent<bool> changeEvent) | ||
{ | ||
_compositeSpriteAnimation.IsLoopableCore = changeEvent.newValue; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/SpriteAnimations/Editor/Scripts/AnimationViews/SpriteAnimationViewComposite.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Assets/SpriteAnimations/Resources/UI Documents/Animations Views/AnimationViewComposite.uxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True"> | ||
<Style src="project://database/Assets/SpriteAnimations/Resources/Styles/AnimationManagerStyles.uss?fileID=7433441132597879392&guid=a292484cf1ed97c4e9a9a18c4bde1c46&type=3#AnimationManagerStyles" /> | ||
<ui:VisualElement name="container" style="flex-grow: 1; flex-direction: row; width: 100%; height: 100%; align-items: flex-start;"> | ||
<ui:VisualElement name="left" style="height: 100%; max-width: 240px; align-items: center; background-color: rgb(31, 4, 9); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;"> | ||
<ui:VisualElement name="animation-preview-container" style="flex-grow: 0; flex-direction: row; align-items: center; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;"> | ||
<ui:VisualElement style="flex-grow: 0; flex-shrink: 0; height: 200px; width: 200px; -unity-background-image-tint-color: rgb(173, 1, 1); background-color: rgb(38, 79, 120);" /> | ||
</ui:VisualElement> | ||
</ui:VisualElement> | ||
<ui:VisualElement name="content" style="flex-grow: 1; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; height: 100%;"> | ||
<ui:VisualElement name="loopable-core-field-container" style="flex-grow: 0; flex-direction: row-reverse; width: 100%; align-items: center; margin-bottom: 0; margin-top: 0; margin-right: 0; margin-left: 0; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;"> | ||
<ui:Toggle label="Loopable core?" name="loopable-core-field" value="true" tooltip="If the Sprite Animator should restart the animation automatically upon its cycle end." style="align-items: center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; -unity-text-align: middle-left;" /> | ||
</ui:VisualElement> | ||
<ui:VisualElement name="tabs-bar" class="tabs-bar"> | ||
<ui:VisualElement name="expander" style="flex-grow: 1;" /> | ||
<ui:Button text="Antecipation" parse-escape-sequences="true" display-tooltip-when-elided="true" name="tab-button-antecipation" view-data-key="antecipation" class="interactable tab-button active" /> | ||
<ui:Button text="Core" parse-escape-sequences="true" display-tooltip-when-elided="true" name="tab-button-core" view-data-key="core" class="interactable tab-button" /> | ||
<ui:Button text="Recovery" parse-escape-sequences="true" display-tooltip-when-elided="true" name="tab-button-recovery" view-data-key="recovery" class="interactable tab-button" /> | ||
</ui:VisualElement> | ||
<ui:VisualElement name="cycle-view" style="flex-grow: 1;" /> | ||
</ui:VisualElement> | ||
</ui:VisualElement> | ||
</ui:UXML> |
10 changes: 10 additions & 0 deletions
10
...SpriteAnimations/Resources/UI Documents/Animations Views/AnimationViewComposite.uxml.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ public enum AnimationType | |
{ | ||
SingleCycle, | ||
Windrose, | ||
Combo | ||
Combo, | ||
Composite | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
Assets/SpriteAnimations/Runtime/Scripts/Animations/SpriteAnimationComposite.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace SpriteAnimations | ||
{ | ||
public class SpriteAnimationComposite : SpriteAnimation | ||
{ | ||
#region Inspector | ||
|
||
[SerializeField] | ||
private Cycle _antecipationCycle; | ||
|
||
[SerializeField] | ||
private Cycle _coreCycle; | ||
|
||
[SerializeField] | ||
private Cycle _recoveryCycle; | ||
|
||
[SerializeField] | ||
private bool _loopableCore; | ||
|
||
#endregion | ||
|
||
#region Getters | ||
|
||
public Cycle AntecipationCycle { get => _antecipationCycle; set => _antecipationCycle = value; } | ||
public Cycle CoreCycle { get => _coreCycle; set => _coreCycle = value; } | ||
public Cycle RecoveryCycle { get => _recoveryCycle; set => _recoveryCycle = value; } | ||
public bool IsLoopableCore { get => _loopableCore; set => _loopableCore = value; } | ||
|
||
public override Type PerformerType => typeof(CompositePerformer); | ||
public override AnimationType AnimationType => AnimationType.Composite; | ||
|
||
#endregion | ||
|
||
#region Cycles | ||
|
||
/// <summary> | ||
/// This must be executed upon the asset creation | ||
/// </summary> | ||
public void GenerateCycles() | ||
{ | ||
_antecipationCycle = new Cycle(this); | ||
_coreCycle = new Cycle(this); | ||
_recoveryCycle = new Cycle(this); | ||
} | ||
|
||
#endregion | ||
|
||
#region Calculations | ||
|
||
public override int CalculateFramesCount() | ||
{ | ||
return _antecipationCycle.Size + _coreCycle.Size + _recoveryCycle.Size; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/SpriteAnimations/Runtime/Scripts/Animations/SpriteAnimationComposite.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.