Skip to content

Commit

Permalink
Merge pull request #70 from brunomikoski/feature/bruno/custom-set-steps
Browse files Browse the repository at this point in the history
add: more meta changes
  • Loading branch information
brunomikoski authored Oct 9, 2023
2 parents 28a13b4 + 90cae24 commit a786134
Show file tree
Hide file tree
Showing 11 changed files with 367 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed


## [0.5.4]
### Added
- Added `Set` steps, this allow you to specifically set properties of your target at a certain point in your sequence, a good example is: You want to have a `In` animation and also `Out` but you want to make sure things looks correct when the animation start, you can now use this to set the properties. Right now only supports `Transform`, `RectTransform` `Graphic` and `Image` but I will extend this overtime if turns out to be useful.


## [0.5.3]
### Changed
- Exposed the `AnimationSteps` from the `AnimationSequencerController`
Expand All @@ -17,7 +22,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `ReplaceTargets(params (GameObject original, GameObject target)[] replacements)` that replaces all the original targets to the newTarget
- Add `ReplaceTargets(GameObject originalTarget, GameObject newTarget)` to replace all the targets of the original target to the new target


## [0.5.2]
### Changed
- Fixed Animation not saving progress changes
Expand Down Expand Up @@ -214,6 +218,7 @@ Thanks for all the [suggestions](https://github.com/brunomikoski/Animation-Seque
### Added
- First initial working version

[0.5.4]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.5.4
[0.5.3]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.5.3
[0.5.2]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.5.2
[0.5.1]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.5.1
Expand Down
3 changes: 2 additions & 1 deletion Scripts/Runtime/Core/AnimationSequencerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ public virtual Sequence GenerateSequence()

for (int i = 0; i < animationSteps.Length; i++)
{
animationSteps[i].AddTweenToSequence(sequence);
AnimationStepBase animationStepBase = animationSteps[i];
animationStepBase.AddTweenToSequence(sequence);
}

sequence.SetTarget(this);
Expand Down
53 changes: 53 additions & 0 deletions Scripts/Runtime/Core/Steps/SetTargetGraphicPropertiesStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

namespace BrunoMikoski.AnimationSequencer
{
[Serializable]
public sealed class SetTargetGraphicPropertiesStep : AnimationStepBase
{
[SerializeField]
private Graphic targetGraphic;

[SerializeField]
private Color targetColor = Color.white;

private Color originalColor;

public override string DisplayName => "Set Target Graphic Properties";
public override void AddTweenToSequence(Sequence animationSequence)
{
Sequence behaviourSequence = DOTween.Sequence();
behaviourSequence.SetDelay(Delay);

behaviourSequence.AppendCallback(() =>
{
originalColor = targetGraphic.color;
targetGraphic.color = targetColor;
});
if (FlowType == FlowType.Join)
animationSequence.Join(behaviourSequence);
else
animationSequence.Append(behaviourSequence);
}

public override void ResetToInitialState()
{
targetGraphic.color = originalColor;
}


public override string GetDisplayNameForEditor(int index)
{
string display = "NULL";
if (targetGraphic != null)
display = targetGraphic.name;

return $"{index}. Set {display} Properties";
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions Scripts/Runtime/Core/Steps/SetTargetImagePropertiesStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

namespace BrunoMikoski.AnimationSequencer
{
[Serializable]
public sealed class SetTargetImagePropertiesStep : AnimationStepBase
{
[SerializeField]
private Image targetGraphic;

[SerializeField]
private Color targetColor = Color.white;
[SerializeField]
private Sprite targetSprite;
[SerializeField]
private Material targetMaterial;

private Color originalColor = Color.white;
private Material originalMaterial;
private Sprite originalSprite;

public override string DisplayName => "Set Target Image Properties";
public override void AddTweenToSequence(Sequence animationSequence)
{
Sequence behaviourSequence = DOTween.Sequence();
behaviourSequence.SetDelay(Delay);

behaviourSequence.AppendCallback(() =>
{

if (targetColor != targetGraphic.color)
{
originalColor = targetGraphic.color;
targetGraphic.color = targetColor;
}

if (targetSprite != null)
{
originalSprite = targetGraphic.sprite;
targetGraphic.sprite = targetSprite;
}

if (targetMaterial != null)
{
originalMaterial = targetGraphic.material;
targetGraphic.material = targetMaterial;
}


});

if (FlowType == FlowType.Join)
animationSequence.Join(behaviourSequence);
else
animationSequence.Append(behaviourSequence);
}

public override void ResetToInitialState()
{
targetGraphic.color = originalColor;

if(originalSprite != null)
targetGraphic.sprite = originalSprite;

if (originalMaterial != null)
targetGraphic.material = targetMaterial;
}

public override string GetDisplayNameForEditor(int index)
{
string display = "NULL";
if (targetGraphic != null)
display = targetGraphic.name;

return $"{index}. Set {display}(Image) Properties";
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions Scripts/Runtime/Core/Steps/SetTargetRectTransformPropertiesStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using UnityEngine;

namespace BrunoMikoski.AnimationSequencer
{
[Serializable]
public sealed class SetTargetRectTransformPropertiesStep : AnimationStepBase
{
public override string DisplayName => "Set Target RectTransform Properties";
[SerializeField]
private RectTransform targetRectTransform;

[SerializeField]
private bool useLocal;
[SerializeField]
private Vector3 position;
[SerializeField]
private Vector3 eulerAngles;
[SerializeField]
private Vector3 scale = Vector3.one;

[SerializeField]
private Vector2 anchorMin = new Vector2(0.5f, 0.5f);
[SerializeField]
private Vector2 anchorMax = new Vector2(0.5f, 0.5f);
[SerializeField]
private Vector2 anchoredPosition;
[SerializeField]
private Vector2 sizeDelta;
[SerializeField]
private Vector2 pivot = new Vector2(0.5f, 0.5f);

private Vector3 originalPosition;
private Vector3 originalEulerAngles;
private Vector3 originalScale;
private Vector2 originalAnchorMin;
private Vector2 originalAnchorMax;
private Vector2 originalAnchoredPosition;
private Vector2 originalSizeDelta;
private Vector2 originalPivot;

public override void AddTweenToSequence(Sequence animationSequence)
{
Sequence behaviourSequence = DOTween.Sequence();
behaviourSequence.SetDelay(Delay);

behaviourSequence.AppendCallback(() =>
{
if (useLocal)
{
originalPosition = targetRectTransform.localPosition;
originalEulerAngles = targetRectTransform.localEulerAngles;

targetRectTransform.localPosition = position;
targetRectTransform.localEulerAngles = eulerAngles;
}
else
{
originalPosition = targetRectTransform.position;
originalEulerAngles = targetRectTransform.eulerAngles;

targetRectTransform.position = position;
targetRectTransform.eulerAngles = eulerAngles;
}


targetRectTransform.anchorMin = anchorMin;
targetRectTransform.anchorMax = anchorMax;
targetRectTransform.anchoredPosition = anchoredPosition;
targetRectTransform.sizeDelta = sizeDelta;
targetRectTransform.pivot = pivot;


originalAnchorMin = targetRectTransform.anchorMin;
originalAnchorMax = targetRectTransform.anchorMax;
originalAnchoredPosition = targetRectTransform.anchoredPosition;
originalSizeDelta = targetRectTransform.sizeDelta;
originalPivot = targetRectTransform.pivot;

originalScale = targetRectTransform.localScale;
targetRectTransform.localScale = scale;
});
if (FlowType == FlowType.Join)
animationSequence.Join(behaviourSequence);
else
animationSequence.Append(behaviourSequence);
}

public override void ResetToInitialState()
{
if (useLocal)
{
targetRectTransform.localPosition = originalPosition;
targetRectTransform.localEulerAngles = originalEulerAngles;
}
else
{
targetRectTransform.position = originalPosition;
targetRectTransform.eulerAngles = originalEulerAngles;
}
targetRectTransform.localScale = originalScale;

targetRectTransform.anchorMin = originalAnchorMin;
targetRectTransform.anchorMax = originalAnchorMax;
targetRectTransform.anchoredPosition = originalAnchoredPosition;
targetRectTransform.sizeDelta = originalSizeDelta;
targetRectTransform.pivot = originalPivot;
}

public override string GetDisplayNameForEditor(int index)
{
string display = "NULL";
if (targetRectTransform != null)
display = targetRectTransform.name;

return $"{index}. Set {display}(RectTransform) Properties";
}

}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a786134

Please sign in to comment.