openVR과 oculus integration 에셋 설치 된 상태에서

 void Start()
    {
        OVRManager.HMDMounted += mounted;
        OVRManager.HMDUnmounted += UnMounted;
    }

    public void mounted()
    {
        Debug.Log("mounted!");
    }
    public void UnMounted()
    {
        Debug.Log("Bye!");
    }

 

스팀VR의 경우는 이렇다.

public class HeadsetDetection : MonoBehaviour
        {       
        public SteamVR_Action_Boolean headsetOnHead = SteamVR_Input.GetBooleanAction("HeadsetOnHead");
                public bool IsHeadsetOnHead;
                public Action OnHeadsetOnHead, OnHeadsetOffHead;
            void Update()
                {
             if (headsetOnHead != null)
                    {
                        if (headsetOnHead.GetStateDown(SteamVR_Input_Sources.Head))
                        {
                            Debug.Log("Headset placed on head");
            
                            IsHeadsetOnHead = true;
            
                            if (OnHeadsetOnHead != null)
                            {
                                OnHeadsetOnHead();
            
                            }
                        }
                        else if (headsetOnHead.GetStateUp(SteamVR_Input_Sources.Head))
                        {
                            Debug.Log("Headset removed");
            
                            IsHeadsetOnHead = false;
                            if (OnHeadsetOffHead != null)
                            {
                                OnHeadsetOffHead();
                            }
                        }
                    }
            }
    }

+ Recent posts