Aimbot-ParallelEnv/Assets/Script/InGame/rayInfoUI.cs

38 lines
1.0 KiB
C#
Raw Normal View History

2022-10-25 19:07:39 +00:00
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class rayInfoUI : MonoBehaviour
{
TextMeshProUGUI infoText;
bool infoTextReady = false;
2022-10-25 19:07:39 +00:00
// Start is called before the first frame update
void Start()
{
try
{
infoText = transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>();
infoTextReady = true;
}
catch (UnityException)
{
infoTextReady = false;
}
2022-10-25 19:07:39 +00:00
}
public void updateInfo(string info,Vector3 infoPosition, Color infoColor,Camera facetoCamera)
2022-10-25 19:07:39 +00:00
{
if (!infoTextReady)
{
infoText = transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>();
}
2022-10-25 19:07:39 +00:00
infoText.text = info;
infoText.color = infoColor;
transform.position = infoPosition;
Vector3 v = facetoCamera.transform.position - infoPosition;
2022-10-25 19:07:39 +00:00
v.x = v.z = 0.0f;
transform.LookAt(facetoCamera.transform.position - v);
2022-10-25 19:07:39 +00:00
transform.Rotate(0, 180, 0);
}
}