private void DoRenderTexture()
        {
            var o = new Utils.OverlayHelper(handle, false);

            if (texture == null || !o.Valid)
            {
                return;
            }

            if (renderCamera)
            {
                renderCamera.Render();
            }

            if (isFacingHmd)
            {
                if (ShouldRenderTexture(texture))
                {
                    o.SetTexture(texture);
                }
                o.FillTextureBounds();
            }
            else
            {
                if (backface == null)
                {
                    if (ShouldRenderTexture(texture))
                    {
                        o.SetTexture(texture);
                    }
                    o.SetTextureBounds(1, 0, 0, 1);
                }
                else
                {
                    if (ShouldRenderTexture(backface))
                    {
                        o.SetTexture(backface);
                    }
                    o.FillTextureBounds();
                }
            }
        }
示例#2
0
        void Update()
        {
            var overlay = OpenVR.Overlay;

            if (overlay == null)
            {
                return;
            }

            if (handle == OpenVR.k_ulOverlayHandleInvalid)
            {
                Utils.CreateOverlay(key, gameObject.name, ref handle);
            }

            var o = new Utils.OverlayHelper(handle);

            if (texture != null && o.Valid)
            {
                o.Show();

                o.SetColorWithAlpha(TransformColor(color));
                o.SetWidthInMeters(width);

                o.SetInputMethod(VROverlayInputMethod.None);
                o.SetMouseScale(1, 1);

                var offset = new SteamVR_Utils.RigidTransform(transform);
                if (Utils.IsFacingHmd(transform))
                {
                    o.SetFullTexture(texture);
                }
                else
                {
                    offset.rot = offset.rot * Quaternion.AngleAxis(180, Vector3.up);
                    if (backface == null)
                    {
                        o.SetTexture(texture);
                        o.SetTextureBounds(1, 0, 0, 1);
                    }
                    else
                    {
                        o.SetFullTexture(backface);
                    }
                }
                o.SetTransformAbsolute(ETrackingUniverseOrigin.TrackingUniverseStanding, offset);
            }
        }