36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.Serialization;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Ichni.Editor
|
|
{
|
|
public abstract class MovableWindow : MonoBehaviour
|
|
{
|
|
public RectTransform windowRect;
|
|
public Button closeButton;
|
|
public TMP_Text title;
|
|
public UnityAction onCloseWindow;
|
|
public UnityAction onQuit;
|
|
|
|
protected void InitializeWindow(string titleText, UnityAction closeAction = null, Vector3 targetScale = default)
|
|
{
|
|
title.text = titleText;
|
|
onCloseWindow = closeAction;
|
|
closeButton.onClick.AddListener(() =>
|
|
{
|
|
onCloseWindow?.Invoke();
|
|
onQuit?.Invoke();
|
|
this.transform.DOScale(Vector3.zero, 0.15f).SetEase(Ease.InCirc).OnComplete(() =>
|
|
{
|
|
Destroy(gameObject);
|
|
});
|
|
});
|
|
this.transform.DOScale(targetScale == default ? Vector3.one : targetScale, 0.2f).SetEase(Ease.OutBack).From(Vector3.zero);
|
|
}
|
|
}
|
|
} |