1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class LIstTextManager : MonoBehaviour
- {
- public Text t;
- public static List<string> showstr=new List<string>();
- List<GameObject> showGame=new List<GameObject>();
- public void showTip()
- {
- if(showstr.Count>0)
- {
-
- this.gameObject.SetActive(true);
- }
- for (int i = 0;i<showstr.Count;i++)
- {
- GameObject go =GameObject.Instantiate( t.gameObject,t.transform.parent);
- go.SetActive(true);
- go.GetComponent<Text>().text = showstr[i];
- showGame.Add(go);
- }
- }
- public void closeTip()
- {
- for (int i = 0;i<showGame.Count;i++)
- {
- Destroy(showGame[i]);
- }
- showGame=new List<GameObject>();
- this.gameObject.SetActive(false);
- }
- private float Px, Py;
- private void Update() {
- float fz =this.transform.parent.localScale.x *this.transform.parent.parent.localScale.x;
- this.transform.GetComponent<RectTransform>().localPosition = new Vector3(-Screen.width/2/fz+Input.mousePosition.x/fz, -Screen.height/2/fz+Input.mousePosition.y /fz ,0);
-
- }
- }
|