lucid-super-dream/Assets/Scripts/PlayGameButton.cs

23 lines
740 B
C#
Raw Normal View History

2021-01-11 11:01:41 +01:00
using DG.Tweening;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
2021-01-11 13:45:37 +01:00
public class PlayGameButton : MonoBehaviour
2021-01-11 11:01:41 +01:00
{
[SerializeField] private string levelName;
[SerializeField] private CanvasGroup group;
[SerializeField] private CanvasGroup thisGroup;
2021-01-11 13:45:37 +01:00
public void Submit()
2021-01-11 11:01:41 +01:00
{
var asyncOp = SceneManager.LoadSceneAsync(levelName);
asyncOp.allowSceneActivation = false;
DOTween.Sequence()
.Append(transform.DOScale(Vector3.one * 1.5f, 0.3f).SetEase(Ease.OutQuint))
.Insert(0.15f, thisGroup.DOFade(0, 0.15f))
.Append(group.DOFade(0, 0.3f))
.AppendCallback(() => asyncOp.allowSceneActivation = true);
}
}