62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using UnityEngine;
|
|
using RainbowArt.CleanFlatUI;
|
|
using Yarn.Unity;
|
|
using System.Collections;
|
|
using DG.Tweening;
|
|
using AibisDream;
|
|
using AibisDream.Kit;
|
|
|
|
public class WindowManager : MonoBehaviour
|
|
{
|
|
public static WindowManager Instance { get; private set; }
|
|
public ModalWindowProgressBar progressWindowPrefab;
|
|
|
|
private GameObject currentWindow;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject); // 如果需要全局保留
|
|
}
|
|
|
|
[YarnCommand("OpenProgressWindow")]
|
|
public IEnumerator OpenProgressWindow(string title, string description, float duration)
|
|
{
|
|
AudioManager.Instance.PlaySfx("event:/Scriptal/Ui");
|
|
progressWindowPrefab.TitleValue = title;
|
|
progressWindowPrefab.DescriptionValue = description;
|
|
float currentProgress = 0;
|
|
|
|
DOTween.To(
|
|
() => currentProgress,
|
|
value =>
|
|
{
|
|
currentProgress = value;
|
|
progressWindowPrefab.SetProgress(currentProgress); // 更新进度
|
|
},
|
|
100,
|
|
duration
|
|
);
|
|
|
|
progressWindowPrefab.ShowModalWindow();
|
|
|
|
// 获取 moveText 的 RectTransform
|
|
RectTransform moveTextRect =
|
|
progressWindowPrefab.transform.Find("View/mask/moveText")?.GetComponent<RectTransform>();
|
|
if (moveTextRect != null)
|
|
{
|
|
moveTextRect.DOAnchorPosY(330f, duration).SetEase(Ease.Linear);
|
|
}
|
|
|
|
// 等待用户确认
|
|
yield return new WaitUntil(() => currentProgress >= 100);
|
|
progressWindowPrefab.HideModalWindow();
|
|
moveTextRect.DOAnchorPosY(-611f, 0.1f).SetEase(Ease.Linear);
|
|
}
|
|
} |