using System.Collections; using System.Collections.Generic; using UnityEngine; public class SynPlayerTransform : MonoSingleton { public Transform player; void Start() { player = OpenXRCamera.Instance.head; } // Update is called once per frame void Update() { transform.eulerAngles = new Vector3(0, player.eulerAngles.y, 0); transform.position = new Vector3(player.position.x, 0, player.position.z); UILogManager.Instance.text3.text = transform.localEulerAngles.y.ToString(); } /// /// 返回当前朝向的机柜 , False 单排机柜 1 3 5... /// /// public bool GetOrientation() { if (Mathf.Abs(transform.localEulerAngles.y) > 90&& Mathf.Abs(transform.localEulerAngles.y)<270) { return true; } return false; } /// /// 判断当前在第几排机柜之间 /// public int GetRowCabinets() { int row = 0; float rowDis = 0; int index = 0; for (int i = 0; i < MachineRoomManager.Instance.listObjes.Count; i+=MachineRoomManager.Instance.data.line*2) { float disZ = Mathf.Abs(transform.position.z - MachineRoomManager.Instance.listObjes[i].transform.position.z); if(rowDis>disZ) { row = index; rowDis = disZ; } index++; } return row; } }