12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.InputSystem.XR;
- using WCQ.CommonV1_20200325;
- [DefaultExecutionOrder(100000)]
- public class SetUpSVRForXR : MonoBehaviour
- {
- [SerializeField]
- private Camera XRCamera;
- [SerializeField]
- private ControllerInputFromAction left;
- [SerializeField]
- private ControllerInputFromAction right;
- private SvrManager svr {
- get {
- return SvrManager.Instance;
- }
- }
- private SC.InputSystem.InputSystem inputsystem {
- get {
- return SC.InputSystem.InputSystem.Instant;
- }
- }
- AddOnCamera addonCamera;
- private void Awake() {
- //DontDestroyOnLoad(gameObject);
- DebugMy.Log("SetUpSVR Awake", this, true);
- if ( XRCamera == null ) {
- DebugMy.LogError("Please Set XRCamera", this);
- }
- if ( svr != null ) {
- svr.gameObject.SetActive(false);
- svr.status.running = true;
- DebugMy.Log("SetUpSVR Finish", this, true);
- addonCamera = XRCamera.gameObject.AddComponent<AddOnCamera>();
- return;
- }
- DebugMy.Log("SetUpSVR Failed", this, true);
- }
- private void LateUpdate()
- {
- // DebugMy.isShowNormalLog = true;
- //for sync headpose from xr
- if ( XRCamera && svr != null ) {
- if (Application.platform == RuntimePlatform.Android)
- {
- svr.head.position = XRCamera.transform.position;
- svr.head.rotation = XRCamera.transform.rotation;
- }
- } else {
- //DebugMy.Log("Cannot sync headpose from xr !", this, true);
- }
- //if (addonCamera )
- //{
- // addonCamera.LeftController = left.Controller;
- // addonCamera.LeftControllerRotation = left.controllerRotation;
- //}
- //if (addonCamera)
- //{
- // addonCamera.RightController = right.Controller;
- // addonCamera.RightControllerRotation = right.controllerRotation;
- //}
- }
- }
|