コード例 #1
0
        private IEnumerator MigrateModel(SteamVR_RenderModel model, IVRAvatarHand hand)
        {
            var controllerVisual = hand.Transform.GetComponentInChildren <VRAvatarController>(includeInactive: true);

            yield return(new WaitUntil(() => model.transform.childCount != 1));

            if (controllerVisual == null)
            {
                model.SetMeshRendererState(false);
                yield break;
            }

            model.transform.SetParent(controllerVisual.transform);
            model.transform.localPosition = Vector3.zero;
            model.transform.localRotation = Quaternion.identity;

            switch (XRDeviceUtils.GetDeviceModelType())
            {
            case EDeviceModelType.HtcVive:
            case EDeviceModelType.HtcViveCosmos:
            case EDeviceModelType.HtcVivePro:

                hand.Anchor.transform.localPosition += new Vector3(0, 0, -0.1f);
                model.transform.localPosition        = new Vector3(0, 0, 0.1f);

                break;
            }

            var pointerVisual = controllerVisual.GetComponentInChildren <LaserPointerVisual>(includeInactive: true);

            pointerVisual.Bind(hand.InputDevice.Pointer);
            hand.InputDevice.Pointer.Transform = pointerVisual.transform;
        }
コード例 #2
0
        private void Start()
        {
            m_Renderer = GetComponent <Renderer>();

            m_Renderer.material.SetFloat("_Quest", 0);
            m_Renderer.material.SetFloat("_Rift", 0);
            m_Renderer.material.SetFloat("_RiftS", 0);
            m_Renderer.material.SetFloat("_Vive", 0);
            m_Renderer.material.SetFloat("_VivePro", 0);

#if UNITY_ANDROID
            m_Renderer.material.SetFloat(s_offsetEnabled, OVRUtils.IsOculusQuest ? 1 : 0);
            m_Renderer.material.SetFloat("_Quest", OVRUtils.IsOculusQuest ? 1 : 0);
#endif
            var model = XRDeviceUtils.GetDeviceModelType();

#if UNITY_STANDALONE
            m_Renderer.material.SetFloat(s_offsetEnabled, 1);

            switch (model)
            {
            case EDeviceModelType.Rift:
                m_Renderer.material.SetFloat("_Rift", 1);
                break;

            case EDeviceModelType.RiftS:
                m_Renderer.material.SetFloat("_RiftS", 1);
                break;

            case EDeviceModelType.HtcVive:
                m_Renderer.material.SetFloat("_Vive", 1);
                break;

            case EDeviceModelType.HtcVivePro:
                m_Renderer.material.SetFloat("_VivePro", 1);
                break;

            case EDeviceModelType.Quest:
                m_Renderer.material.SetFloat("_Quest", 1);
                break;
            }
#endif

            if (model == EDeviceModelType.Quest2)
            {
                m_Renderer.material.SetFloat("_Quest", 0);
                m_Renderer.material.SetFloat(s_offsetEnabled, 1);
                m_Renderer.material.SetFloat("_Debug", 1);

                SetMaterial(IpdModel);
            }

            void SetMaterial(ReflectionOffsetModel m)
            {
                m_Renderer.material.SetFloat("_OffsetRX", m.RX);
                m_Renderer.material.SetFloat("_OffsetRY", m.RY);
                m_Renderer.material.SetFloat("_OffsetRZ", m.RZ);
                m_Renderer.material.SetFloat("_OffsetRW", m.RW);
                m_Renderer.material.SetFloat("_OffsetX", m.LOffset);

                m_Renderer.material.SetFloat("_UseL", m.UseL ? 1 : 0);
                m_Renderer.material.SetFloat("_OffsetLX", m.LX);
                m_Renderer.material.SetFloat("_OffsetLZ", m.LZ);
            }
        }