2022-10-25 19:07:39 +00:00
|
|
|
using TMPro;
|
2023-06-30 09:30:12 +00:00
|
|
|
using UnityEngine;
|
2022-10-25 19:07:39 +00:00
|
|
|
|
2023-06-30 09:30:12 +00:00
|
|
|
public class RayInfoUI : MonoBehaviour
|
2022-10-25 19:07:39 +00:00
|
|
|
{
|
2023-06-30 09:30:12 +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
|
2023-06-30 09:30:12 +00:00
|
|
|
private void Start()
|
2022-10-25 19:07:39 +00:00
|
|
|
{
|
2022-11-02 22:07:51 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
infoText = transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>();
|
|
|
|
infoTextReady = true;
|
|
|
|
}
|
|
|
|
catch (UnityException)
|
|
|
|
{
|
|
|
|
infoTextReady = false;
|
|
|
|
}
|
2022-10-25 19:07:39 +00:00
|
|
|
}
|
|
|
|
|
2023-06-30 09:30:12 +00:00
|
|
|
public void UpdateInfo(string info, Vector3 infoPosition, Color infoColor, Camera facetoCamera)
|
2022-10-25 19:07:39 +00:00
|
|
|
{
|
2022-11-02 22:07:51 +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;
|
2022-11-02 22:07:51 +00:00
|
|
|
Vector3 v = facetoCamera.transform.position - infoPosition;
|
2022-10-25 19:07:39 +00:00
|
|
|
v.x = v.z = 0.0f;
|
2022-11-02 22:07:51 +00:00
|
|
|
transform.LookAt(facetoCamera.transform.position - v);
|
2022-10-25 19:07:39 +00:00
|
|
|
transform.Rotate(0, 180, 0);
|
|
|
|
}
|
2023-06-30 09:30:12 +00:00
|
|
|
}
|