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.
36 lines
1.3 KiB
36 lines
1.3 KiB
using UnityEngine; |
|
using UnityEngine.Events; |
|
using UnityEngine.UI; |
|
public class InputWindowManager : MonoBehaviour { |
|
|
|
public void SetWindow(string tips, UnityAction OKFunction, UnityAction NOFunction) |
|
{ |
|
transform.name = "TheInputWindow"; |
|
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); |
|
} |
|
GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0); |
|
transform.Find("TitleText").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); |
|
} |
|
}
|
|
|