12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using GHZLangChao;
- using UnityEngine;
- /// <summary>
- /// 重置位置---Action
- /// </summary>
- public class ResetTransform : MonoBehaviour
- {
- [SerializeField] private Transform Xunjian => SceneIOCContainer.Instance.Pull("Dof") as Transform;
- public bool FixedHeight;
- private float height;
- private bool heightIsNull;
- private void Awake()
- {
- if(OpenXRCamera.Instance!=null)
- height = OpenXRCamera.Instance.head.position.y;
- else
- heightIsNull = true;
- }
- private void Start()
- {
- if(heightIsNull)
- height = OpenXRCamera.Instance.head.position.y;
- }
- public void Execute()
- {
- transform.position = Xunjian.position;
- transform.eulerAngles = Xunjian.eulerAngles;
- /*
- transform.LookAt(OpenXRCamera.Instance.head);
- transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y + 180f, 0);
- Transform Player = OpenXRCamera.Instance.head;
- Player.eulerAngles = new Vector3(0, OpenXRCamera.Instance.head.eulerAngles.y, 0);
- transform.position = OpenXRCamera.Instance.head.position + Player.forward * 1.6f;
- transform.position = new Vector3(transform.position.x, transform.position.y + 0f, transform.position.z);
- */
- }
- public void FixedHeightExecute()
- {
- Vector3 v3 = Xunjian.position;
- v3.y = height;
- transform.position = v3;
- Vector3 v3Rot = Xunjian.eulerAngles;
- v3Rot = new Vector3(0, v3Rot.y, 0);
- transform.eulerAngles = v3Rot;
- }
- }
|