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.
39 lines
1.3 KiB
39 lines
1.3 KiB
3 years ago
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class TipWindowManager : MonoBehaviour {
|
||
|
|
||
|
|
||
|
public void SetWindow(string tips, UnityEngine.Events.UnityAction OKFunction, UnityEngine.Events.UnityAction NOFunction)
|
||
|
{
|
||
|
transform.name = "TheTipWindow";
|
||
|
transform.SetParent(GameObject.Find("Canvas").transform);
|
||
|
if (transform.parent.GetComponent<CanvasScaler>().referenceResolution.x != 1920)
|
||
|
{
|
||
|
transform.localScale = new Vector3(0.6f, 0.6f, 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
transform.localScale = new Vector3(1, 1, 1);
|
||
|
}
|
||
|
//transform.localScale = new Vector3(1, 1, 1);
|
||
|
GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0);
|
||
|
transform.Find("Text").GetComponent<Text>().text = tips;
|
||
|
if (OKFunction != null)
|
||
|
{
|
||
|
transform.Find("sure").GetComponent<Button>().onClick.AddListener(OKFunction);
|
||
|
}
|
||
|
if (NOFunction != null)
|
||
|
{
|
||
|
transform.Find("close").GetComponent<Button>().onClick.AddListener(NOFunction);
|
||
|
}
|
||
|
//销毁窗口
|
||
|
transform.Find("sure").GetComponent<Button>().onClick.AddListener(DestroyWindow);
|
||
|
transform.Find("close").GetComponent<Button>().onClick.AddListener(DestroyWindow);
|
||
|
}
|
||
|
private void DestroyWindow()
|
||
|
{
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
}
|