网演高层钦州
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.3 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class TipWindowManager : MonoBehaviour {
public UnityAction Sure { get; set; }
public UnityAction Cancel { get; set; }
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
/// <summary>
/// 设置带“确定”、“取消”按钮的提示窗口
/// </summary>
/// <param name="tips">提示信息内容</param>
/// <param name="sureFunc">提示窗口确定</param>
/// <param name="cancelFunc">提示窗口取消</param>
public void SetWindow(string tips, UnityAction sureFunc, UnityAction cancelFunc)
{
Sure = sureFunc;
Cancel = cancelFunc == null ? () => { DestroyWindow(); } : cancelFunc;
transform.SetParent(GameObject.Find("Canvas").transform, false);
GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -320);
transform.Find("TipContent").GetComponent<Text>().text = tips;
transform.Find("Sure").GetComponent<Button>().onClick.AddListener(DestroyWindow);
transform.Find("Cancel").GetComponent<Button>().onClick.AddListener(DestroyWindow);
}
public void DestroyWindow()
{
Destroy(gameObject);
}
}