Skip to content

Commit

Permalink
demo: add tweener demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Dec 11, 2024
1 parent 4e1ba53 commit 43a3c2a
Show file tree
Hide file tree
Showing 6 changed files with 6,244 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assets/Demos/UIEffectTweenerControl.meta

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

60 changes: 60 additions & 0 deletions Assets/Demos/UIEffectTweenerControl/UIEffectTweenerControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Coffee.UIEffects;
using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(UIEffectTweener))]
public class UIEffectTweenerControl : MonoBehaviour
{
[SerializeField]
private Text m_Info;

[SerializeField]
private Slider m_SeekBar;

[SerializeField]
private GameObject m_SeekBarBgInterval1;

[SerializeField]
private GameObject m_SeekBarBgDuration2;

[SerializeField]
private GameObject m_SeekBarBgInterval2;

private UIEffectTweener _tweener;
private UIEffectTweener tweener => _tweener != null ? _tweener : GetComponent<UIEffectTweener>();

private void Update()
{
if (m_Info)
{
var tw = tweener;
m_Info.text =
$"{tw.time:F2}/{tw.totalTime:F2} ({tw.rate:F2}), {tw.direction}, isTweening={tw.isTweening}, isDelaying={tw.isDelaying}, isPaused={tw.isPaused}";
}

if (m_SeekBar)
{
m_SeekBar.value = tweener.time / tweener.totalTime;
}

if (m_SeekBarBgInterval1)
{
m_SeekBarBgInterval1.SetActive(UIEffectTweener.WrapMode.Loop <= tweener.wrapMode);
}

if (m_SeekBarBgDuration2)
{
m_SeekBarBgDuration2.SetActive(UIEffectTweener.WrapMode.PingPongOnce <= tweener.wrapMode);
}

if (m_SeekBarBgInterval2)
{
m_SeekBarBgInterval2.SetActive(UIEffectTweener.WrapMode.PingPongLoop <= tweener.wrapMode);
}
}

public void SetWrapMode(int value)
{
tweener.wrapMode = (UIEffectTweener.WrapMode)value;
}
}
11 changes: 11 additions & 0 deletions Assets/Demos/UIEffectTweenerControl/UIEffectTweenerControl.cs.meta

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

Loading

0 comments on commit 43a3c2a

Please sign in to comment.