Unity/유니티VR
[유니티 VR] 장치 인식 코드
도이(doi)
2021. 10. 27. 11:11
728x90
VR 장치가 연결되어 있는지 확인할 수 있는 코드.
VR이 장비가 연결되어 있는지 아닌지에 대한 확인을 해서
연결이 안되어 있을 때는 PC로 전환되도록 작업할 수 있도록 구현 중....!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class vrDeviceDetector : MonoBehaviour
{
private void Start()
{
var inputDevices = new List<UnityEngine.XR.InputDevice>();
InputDevices.GetDevices(inputDevices);
foreach(var device in inputDevices)
{
Debug.Log(string.Format("Device found with name'{0}' and role '{1}'", device.name, device.role.ToString()));
if(device.name == "Oculus Quest2")
{
Debug.Log("detected device");
}
}
}
}
728x90
반응형