perf
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.UI
|
||||
@@ -21,24 +22,42 @@ namespace Ichni.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeIn(float duration = 0.5f)
|
||||
public void FadeIn(float duration = 0.5f, bool ignoreTimeScale = false, UnityAction action = null)
|
||||
{
|
||||
mainCanvasGroup.gameObject.SetActive(true);
|
||||
mainCanvasGroup.DOFade(1f, duration).OnComplete(() =>
|
||||
|
||||
Tweener fade = mainCanvasGroup.DOFade(1f, duration).OnComplete(() =>
|
||||
{
|
||||
mainCanvasGroup.interactable = true;
|
||||
mainCanvasGroup.blocksRaycasts = true;
|
||||
}).Play();
|
||||
action?.Invoke();
|
||||
});
|
||||
|
||||
if (ignoreTimeScale)
|
||||
{
|
||||
fade.SetUpdate(true);
|
||||
}
|
||||
|
||||
fade.Play();
|
||||
}
|
||||
|
||||
public void FadeOut(float duration = 0.5f)
|
||||
public void FadeOut(float duration = 0.5f, bool ignoreTimeScale = false, UnityAction action = null)
|
||||
{
|
||||
mainCanvasGroup.interactable = false;
|
||||
mainCanvasGroup.blocksRaycasts = false;
|
||||
mainCanvasGroup.DOFade(0f, duration).OnComplete(() =>
|
||||
|
||||
Tweener fade = mainCanvasGroup.DOFade(0f, duration).OnComplete(() =>
|
||||
{
|
||||
action?.Invoke();
|
||||
mainCanvasGroup.gameObject.SetActive(false);
|
||||
}).Play();
|
||||
});
|
||||
|
||||
if (ignoreTimeScale)
|
||||
{
|
||||
fade.SetUpdate(true);
|
||||
}
|
||||
|
||||
fade.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user