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

37 lines
1.0 KiB
C#
Raw Normal View History

2022-10-25 19:07:39 +00:00
using TMPro;
using UnityEngine;
2022-10-25 19:07:39 +00:00
public class RayInfoUI : MonoBehaviour
2022-10-25 19:07:39 +00:00
{
private TextMeshProUGUI infoText;
private bool infoTextReady = false;
2022-10-25 19:07:39 +00:00
// Start is called before the first frame update
private void Start()
2022-10-25 19:07:39 +00:00
{
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);
}
}