using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TipsUI : MonoBehaviour { public static TipsUI Instance; public CanvasGroup group => GetComponentInChildren(); public Text textContent => GetComponentInChildren(); private GameObject jie; void Start() { Instance = this; group.alpha = 0; } void Update() { if (jie != null) { transform.localPosition = Camera.main.WorldToScreenPoint(jie.transform.position); } } /// /// 提示UI /// /// 传进来物体的数据名字位置信息 public void OpenUI(GameObject obj) { group.alpha = 1f; textContent.text = obj.name; jie = obj; } /// /// 关闭提示UI /// public void OffUI() { group.alpha = 0f; jie = null; } }