12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System.Collections;
- using System.Collections.Generic;
- using TMPro;
- using UnityEngine;
- public class RoadManager : MonoBehaviour
- {
- public GameObject EndGo;
- public GameObject StartGo;
- public TextMeshProUGUI textMeshPro;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- textMeshPro.transform.position = OpenXRCamera.Instance.head.position+OpenXRCamera.Instance.head.forward;
- textMeshPro.transform.position = new Vector3(textMeshPro.transform.position.x, textMeshPro.transform.position.y-0.3f, textMeshPro.transform.position.z);
- textMeshPro.transform.LookAt(OpenXRCamera.Instance.head);
- textMeshPro.transform.eulerAngles = new Vector3(0, textMeshPro.transform.eulerAngles.y+180, 0);
- StartGo.transform.LookAt(EndGo.transform);
- StartGo.transform.eulerAngles = new Vector3(90, StartGo.transform.eulerAngles.y,0);
- float f = StartGo.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y;
- if ((f)>0|| (f) < -180)
- {
- textMeshPro.text = "ÏòÓÒ¿´";
- if (Mathf.Abs(f) > 90)
- {
- StartGo.transform.eulerAngles = new Vector3(90, 90+ OpenXRCamera.Instance.head.eulerAngles.y, 0);
- }
- }
- else
- {
- textMeshPro.text = "Ïò×ó¿´";
- if (Mathf.Abs(f) > 90)
- {
- StartGo.transform.eulerAngles = new Vector3(90, 90 + OpenXRCamera.Instance.head.eulerAngles.y+180, 0);
- }
- }
- if(Mathf.Abs(f) < 45)
- {
- textMeshPro.enabled=false;
- }else
- {
- textMeshPro.enabled = true;
- }
- }
- }
|