43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class VRControllerButton : MonoBehaviour
|
|
{
|
|
public GameObject model;
|
|
|
|
public GameObject infoParent;
|
|
|
|
public Text infoText;
|
|
|
|
public Transform lineModel;
|
|
|
|
private VRControllersManager vRControllersManager;
|
|
|
|
private void Start()
|
|
{
|
|
vRControllersManager = VRControllersManager.Instance;
|
|
if (infoParent == null)
|
|
{
|
|
infoParent = base.gameObject;
|
|
}
|
|
infoText.resizeTextMaxSize = vRControllersManager.textSize;
|
|
infoText.GetComponent<Outline>().enabled = vRControllersManager.textOutline;
|
|
lineModel.localScale = new Vector3(vRControllersManager.lineScale, lineModel.localScale.y, vRControllersManager.lineScale);
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (vRControllersManager.textFacingCamera && (bool)Camera.main)
|
|
{
|
|
infoText.transform.LookAt(infoText.transform.position + Camera.main.transform.rotation * Vector3.forward, Camera.main.transform.rotation * Vector3.up);
|
|
infoText.transform.eulerAngles = new Vector3(infoText.transform.eulerAngles.x, infoText.transform.eulerAngles.y, 0f);
|
|
}
|
|
}
|
|
|
|
public void UpdateInfoText(string newInfoText)
|
|
{
|
|
base.gameObject.SetActive(true);
|
|
infoText.text = newInfoText.ToLower();
|
|
}
|
|
}
|