流程和功能迭代
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using UnityEngine;
|
||||
using RainbowArt.CleanFlatUI;
|
||||
using Yarn.Unity;
|
||||
using System.Collections;
|
||||
|
||||
public class WindowManager : MonoBehaviour
|
||||
{
|
||||
public static WindowManager Instance { get; private set; }
|
||||
|
||||
[Header("Window Prefabs")]
|
||||
public ModalWindow singleButtonWindowPrefab;
|
||||
|
||||
public ModalWindow ImageSingleButtonWindowPrefab;
|
||||
public ModalWindowProgressBar progressWindowPrefab;
|
||||
|
||||
private GameObject currentWindow;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject); // 如果需要全局保留
|
||||
}
|
||||
|
||||
[YarnCommand("OpenSingleButtonWindow")]
|
||||
public IEnumerator OpenSingleButtonWindow(string title, string description)
|
||||
{
|
||||
bool isConfirmed = false;
|
||||
|
||||
singleButtonWindowPrefab.TitleValue = title;
|
||||
singleButtonWindowPrefab.DescriptionValue = description;
|
||||
singleButtonWindowPrefab.OnConfirm.AddListener(() => isConfirmed = true);
|
||||
|
||||
singleButtonWindowPrefab.gameObject.SetActive(true);
|
||||
|
||||
// 等待用户确认
|
||||
yield return new WaitUntil(() => isConfirmed);
|
||||
|
||||
singleButtonWindowPrefab.OnConfirm.RemoveAllListeners();
|
||||
}
|
||||
[YarnCommand("OpenProgressWindow")]
|
||||
public IEnumerator OpenProgressWindow(string title, string description)
|
||||
{
|
||||
bool isConfirmed = false;
|
||||
|
||||
progressWindowPrefab.TitleValue = title;
|
||||
progressWindowPrefab.DescriptionValue = description;
|
||||
progressWindowPrefab.OnFinish.AddListener(() => isConfirmed = true);
|
||||
progressWindowPrefab.gameObject.SetActive(true);
|
||||
|
||||
// 等待用户确认
|
||||
yield return new WaitUntil(() => isConfirmed);
|
||||
progressWindowPrefab.OnFinish.RemoveAllListeners();
|
||||
}
|
||||
[YarnCommand("OpenImageWindow_UFImage")]
|
||||
public void OpenImageSingleButtonWindowPrefab(string title, string imageName)
|
||||
{
|
||||
//bool isConfirmed = false;
|
||||
ImageSingleButtonWindowPrefab.IsConfirmButtonActive=false;
|
||||
ImageSingleButtonWindowPrefab.TitleValue = title;
|
||||
ImageSingleButtonWindowPrefab.ImageValue=Resources.Load<Sprite>("Art/Photos/" + imageName);
|
||||
ImageSingleButtonWindowPrefab.DescriptionValue="";
|
||||
//progressWindowPrefab.OnFinish.AddListener(() => isConfirmed = true);
|
||||
progressWindowPrefab.gameObject.SetActive(true);
|
||||
}
|
||||
[YarnCommand("EnableAndWaitForClosingUFImage")]
|
||||
public IEnumerator EnableAndWaitForClosingUFImage()
|
||||
{
|
||||
bool isConfirmed = false;
|
||||
ImageSingleButtonWindowPrefab.IsConfirmButtonActive=true;
|
||||
yield return new WaitUntil(() => isConfirmed);
|
||||
progressWindowPrefab.OnFinish.RemoveAllListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce44f06ac32fc8f4292c581f5c413b23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user