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.

49 lines
1002 B

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