Initial commit: Client Doc docs Server Tools
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace XWorld
|
||||
{
|
||||
//协程等待对话框关闭
|
||||
public class WaitForDialogClose : CustomYieldInstruction
|
||||
{
|
||||
private bool _isClosed;
|
||||
|
||||
public override bool keepWaiting => !_isClosed; // 对话框未关闭时持续等待
|
||||
|
||||
public void OnDialogClosed() => _isClosed = true;
|
||||
}
|
||||
public class WaitDialogController
|
||||
{
|
||||
// 关闭事件(网页4的消息管理思想)
|
||||
public UnityEvent OnClose;
|
||||
WaitForDialogClose waitObj;
|
||||
|
||||
public void CloseDialog()
|
||||
{
|
||||
waitObj?.OnDialogClosed();
|
||||
}
|
||||
|
||||
IEnumerator ShowDialogCoroutine(Button CloseButton)
|
||||
{
|
||||
CloseButton.onClick.AddListener(() =>
|
||||
{
|
||||
CloseDialog();
|
||||
});
|
||||
waitObj = new WaitForDialogClose();
|
||||
yield return waitObj; // 协程在此处暂停,直到对话框关闭
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user