35 lines
760 B
C#
35 lines
760 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using Unity.XR.CoreUtils;
|
|
|
|
public class RecenterOrigin : MonoBehaviour
|
|
{
|
|
public Transform head;
|
|
public Transform origin;
|
|
public Transform target;
|
|
public InputActionProperty recenterButton;
|
|
|
|
public void Start()
|
|
{
|
|
|
|
}
|
|
|
|
public void Recenter()
|
|
{
|
|
XROrigin xrOrigin = GetComponent<XROrigin>();
|
|
xrOrigin.MoveCameraToWorldLocation(target.position);
|
|
xrOrigin.MatchOriginUpCameraForward(target.up,target.forward);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (recenterButton.action.WasPressedThisFrame())
|
|
{
|
|
Recenter();
|
|
}
|
|
}
|
|
}
|