popcorn/popcorn/Assets/MyGame/Scripts/DialogCloser.cs

29 lines
797 B
C#

using System;
using I2.Loc;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
namespace MyGame.Scripts
{
public class DialogCloser : MonoBehaviour
{
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
[SerializeField] private Animator backgroundAnimator;
[SerializeField] private Button closeButton;
private void Start()
{
closeButton.OnClickAsObservable().Take(1).Subscribe(_ =>
{
transform.SetLocalScale(0);
backgroundAnimator.SetTrigger(CloseTrigger);
this.CallWaitForSeconds(.25f, () =>
{
transform.parent.gameObject.SetActive(false);
});
}).AddTo(this);
}
}
}