コード例 #1
0
    public void UpdateOverlay()
    {
        CVROverlay overlay = OpenVR.Overlay;

        if (overlay == null)
        {
            return;
        }
        if (this.texture != null)
        {
            EVROverlayError evroverlayError = overlay.ShowOverlay(this.handle);
            if ((evroverlayError == EVROverlayError.InvalidHandle || evroverlayError == EVROverlayError.UnknownOverlay) && overlay.FindOverlay(SteamVR_Overlay.key, ref this.handle) != EVROverlayError.None)
            {
                return;
            }
            Texture_t texture_t = default(Texture_t);
            texture_t.handle      = this.texture.GetNativeTexturePtr();
            texture_t.eType       = SteamVR.instance.textureType;
            texture_t.eColorSpace = EColorSpace.Auto;
            overlay.SetOverlayTexture(this.handle, ref texture_t);
            overlay.SetOverlayAlpha(this.handle, this.alpha);
            overlay.SetOverlayWidthInMeters(this.handle, this.scale);
            overlay.SetOverlayAutoCurveDistanceRangeInMeters(this.handle, this.curvedRange.x, this.curvedRange.y);
            VRTextureBounds_t vrtextureBounds_t = default(VRTextureBounds_t);
            vrtextureBounds_t.uMin = this.uvOffset.x * this.uvOffset.z;
            vrtextureBounds_t.vMin = (1f + this.uvOffset.y) * this.uvOffset.w;
            vrtextureBounds_t.uMax = (1f + this.uvOffset.x) * this.uvOffset.z;
            vrtextureBounds_t.vMax = this.uvOffset.y * this.uvOffset.w;
            overlay.SetOverlayTextureBounds(this.handle, ref vrtextureBounds_t);
            HmdVector2_t hmdVector2_t = default(HmdVector2_t);
            hmdVector2_t.v0 = this.mouseScale.x;
            hmdVector2_t.v1 = this.mouseScale.y;
            overlay.SetOverlayMouseScale(this.handle, ref hmdVector2_t);
            SteamVR_Camera steamVR_Camera = SteamVR_Render.Top();
            if (steamVR_Camera != null && steamVR_Camera.origin != null)
            {
                SteamVR_Utils.RigidTransform rigidTransform = new SteamVR_Utils.RigidTransform(steamVR_Camera.origin, base.transform);
                rigidTransform.pos.x = rigidTransform.pos.x / steamVR_Camera.origin.localScale.x;
                rigidTransform.pos.y = rigidTransform.pos.y / steamVR_Camera.origin.localScale.y;
                rigidTransform.pos.z = rigidTransform.pos.z / steamVR_Camera.origin.localScale.z;
                rigidTransform.pos.z = rigidTransform.pos.z + this.distance;
                HmdMatrix34_t hmdMatrix34_t = rigidTransform.ToHmdMatrix34();
                overlay.SetOverlayTransformAbsolute(this.handle, SteamVR_Render.instance.trackingSpace, ref hmdMatrix34_t);
            }
            overlay.SetOverlayInputMethod(this.handle, this.inputMethod);
            if (this.curved || this.antialias)
            {
                this.highquality = true;
            }
            if (this.highquality)
            {
                overlay.SetHighQualityOverlay(this.handle);
                overlay.SetOverlayFlag(this.handle, VROverlayFlags.Curved, this.curved);
                overlay.SetOverlayFlag(this.handle, VROverlayFlags.RGSS4X, this.antialias);
            }
            else if (overlay.GetHighQualityOverlay() == this.handle)
            {
                overlay.SetHighQualityOverlay(0UL);
            }
        }
        else
        {
            overlay.HideOverlay(this.handle);
        }
    }