Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question how can i get actual screen resolution of VR while using PC streaming?

Discussion in 'VR' started by KiraSnow, Dec 6, 2022.

  1. KiraSnow

    KiraSnow

    Joined:
    Feb 22, 2021
    Posts:
    19
    hi i'm trying to write some kind of screen effect but requires a compute buffer which size equals to screen.
    on the desktop i use Screen.Width*Screen.Height to get it, and the effect is work fine,
    but that has error on VR due to wrong buffer size, that the value get from Screen seems like still the desktop screen while i'm streaming VR .

    i did try to use VRSettings.eyeTextureWidth according to this: https://docs.unity3d.com/ScriptReference/Screen-currentResolution.html
    but the value i got always be zero while i'm using streaming.
     
  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    367
    What kind of streaming are you doing? What XR plugin are you using? Quest link?
     
  3. KiraSnow

    KiraSnow

    Joined:
    Feb 22, 2021
    Posts:
    19
    OpenXR + SteamVR
    Sorry for my late reply.
     
    Last edited: Dec 12, 2022
  4. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    367
    It may be because you're trying to access the eye texture size on startup - XR takes a few frames to start and we won't know eye texture size until the textures are actually created. You can do something like this to get them as early as possible:


    Code (CSharp):
    1.     void Start()
    2.     {
    3.         StartCoroutine(WidthHeight());
    4.     }
    5.  
    6.     IEnumerator WidthHeight()
    7.     {
    8.         while (XRSettings.eyeTextureWidth == 0)
    9.             yield return new WaitForEndOfFrame();
    10.         Debug.Log($"w: {XRSettings.eyeTextureWidth} h: {XRSettings.eyeTextureHeight}");
    11.     }