1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System.Collections;
- using System.Collections.Generic;
- using TMPro;
- using UnityEngine;
- public class RoadManager : MonoSingleton<RoadManager>
- {
- public GameObject StartGo;
- public GameObject StartGo2;
- public TextMeshProUGUI textMeshPro;
- // Start is called before the first frame update
- void Start()
- {
- close();
- }
- public void close()
- {
- StartGo2.SetActive(false);
- textMeshPro.enabled = false;
- }
- // 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);*/
-
- }
- public void setFX(Vector3 end)
- {
- StartGo2.SetActive(true);
- textMeshPro.enabled = true;
- StartGo.transform.position =new Vector3(OpenXRCamera.Instance.head.position.x, end.y, OpenXRCamera.Instance.head.position.z);
- StartGo.transform.LookAt(end);
- StartGo.transform.localEulerAngles = new Vector3(0, StartGo.transform.localEulerAngles.y, 0);
- float f = StartGo.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y;
- if (((f) > 0&&f<180) || (f) < -180)
- {
- textMeshPro.text = "向右看" + Vector3.Distance(StartGo.transform.position, end);
- if (Mathf.Abs(f) > 90)
- {
- StartGo.transform.eulerAngles = new Vector3(0, 90 + OpenXRCamera.Instance.head.eulerAngles.y, 0);
- StartGo.transform.localEulerAngles = new Vector3(0, StartGo.transform.localEulerAngles.y, 0);
- }
- }
- else
- {
- textMeshPro.text = "向左看" + Vector3.Distance(StartGo.transform.position, end);
- if (Mathf.Abs(f) > 90)
- {
- StartGo.transform.eulerAngles = new Vector3(0, 90 + OpenXRCamera.Instance.head.eulerAngles.y + 180, 0);
- StartGo.transform.localEulerAngles = new Vector3(0, StartGo.transform.localEulerAngles.y, 0);
- }
- }
- if (Mathf.Abs(f) < 45)
- {
- StartGo2.SetActive(false);
- textMeshPro.enabled = false;
- }
- else
- {
- StartGo2.gameObject.SetActive(true);
- textMeshPro.enabled = true;
- }
- if(Vector3.Distance(new Vector3( StartGo.transform.position.x, end.y, StartGo.transform.position.z), end)<=0.2f)
- {
- StartGo2.SetActive(false);
- textMeshPro.enabled = false;
- }
- StartGo2.transform.localEulerAngles = new Vector3(0, StartGo.transform.localEulerAngles.y, 0);
- }
- }
|