Files
dingyuntian 9f20ef52d8 UI工具翻新
1. 增加UI工具
2. 增加设置页面
3. GameLoop更新
4. 导入ActionKit工具
2025-04-21 18:53:30 +08:00

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);
}
}