73 lines
1.8 KiB
C#
73 lines
1.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
|
|
namespace UnityEngine.UI.CoroutineTween
|
|
{
|
|
// Token: 0x02000038 RID: 56
|
|
internal class TweenRunner<T> where T : struct, ITweenValue
|
|
{
|
|
// Token: 0x06000174 RID: 372 RVA: 0x0000697C File Offset: 0x00004D7C
|
|
private static IEnumerator Start(T tweenInfo)
|
|
{
|
|
if (!tweenInfo.ValidTarget())
|
|
{
|
|
yield break;
|
|
}
|
|
float elapsedTime = 0f;
|
|
while (elapsedTime < tweenInfo.duration)
|
|
{
|
|
elapsedTime += ((!tweenInfo.ignoreTimeScale) ? Time.deltaTime : Time.unscaledDeltaTime);
|
|
float percentage = Mathf.Clamp01(elapsedTime / tweenInfo.duration);
|
|
tweenInfo.TweenValue(percentage);
|
|
yield return null;
|
|
}
|
|
tweenInfo.TweenValue(1f);
|
|
yield break;
|
|
}
|
|
|
|
// Token: 0x06000175 RID: 373 RVA: 0x0000699E File Offset: 0x00004D9E
|
|
public void Init(MonoBehaviour coroutineContainer)
|
|
{
|
|
this.m_CoroutineContainer = coroutineContainer;
|
|
}
|
|
|
|
// Token: 0x06000176 RID: 374 RVA: 0x000069A8 File Offset: 0x00004DA8
|
|
public void StartTween(T info)
|
|
{
|
|
if (this.m_CoroutineContainer == null)
|
|
{
|
|
Debug.LogWarning("Coroutine container not configured... did you forget to call Init?");
|
|
}
|
|
else
|
|
{
|
|
this.StopTween();
|
|
if (!this.m_CoroutineContainer.gameObject.activeInHierarchy)
|
|
{
|
|
info.TweenValue(1f);
|
|
}
|
|
else
|
|
{
|
|
this.m_Tween = TweenRunner<T>.Start(info);
|
|
this.m_CoroutineContainer.StartCoroutine(this.m_Tween);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000177 RID: 375 RVA: 0x00006A28 File Offset: 0x00004E28
|
|
public void StopTween()
|
|
{
|
|
if (this.m_Tween != null)
|
|
{
|
|
this.m_CoroutineContainer.StopCoroutine(this.m_Tween);
|
|
this.m_Tween = null;
|
|
}
|
|
}
|
|
|
|
// Token: 0x040000B4 RID: 180
|
|
protected MonoBehaviour m_CoroutineContainer;
|
|
|
|
// Token: 0x040000B5 RID: 181
|
|
protected IEnumerator m_Tween;
|
|
}
|
|
}
|