32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
// Automatically spawns the XR Interaction Simulator when running in the Editor or on PC.
|
||
|
|
// Add this to any persistent GameObject in the Menu scene (e.g. VR_Manager).
|
||
|
|
//
|
||
|
|
// Setup:
|
||
|
|
// 1. Attach this script to VR_Manager (or any root object) in Menu.unity
|
||
|
|
// 2. In Package Manager → XR Interaction Toolkit → Samples → import "XR Interaction Simulator"
|
||
|
|
// 3. Drag the imported prefab into the SimulatorPrefab field:
|
||
|
|
// Assets/Samples/XR Interaction Toolkit/<version>/XR Interaction Simulator/XR Interaction Simulator.prefab
|
||
|
|
//
|
||
|
|
// Controls (XR Interaction Simulator):
|
||
|
|
// Right-click drag — rotate head
|
||
|
|
// G + mouse move — move right controller
|
||
|
|
// Shift+G — left controller
|
||
|
|
// Space — trigger (UI click)
|
||
|
|
public class XRSimulatorLoader : MonoBehaviour
|
||
|
|
{
|
||
|
|
[SerializeField] private GameObject simulatorPrefab;
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
#if !UNITY_ANDROID || UNITY_EDITOR
|
||
|
|
if (simulatorPrefab != null)
|
||
|
|
Instantiate(simulatorPrefab);
|
||
|
|
else
|
||
|
|
Debug.LogWarning("[XRSimulatorLoader] simulatorPrefab is not assigned.\n" +
|
||
|
|
"Import the XR Interaction Simulator sample via Package Manager and assign the prefab.");
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
}
|