Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How To Get Screen Size Width Height.

Discussion in 'Project Tiny' started by BaspooGameDev, Nov 27, 2020.

  1. BaspooGameDev

    BaspooGameDev

    Joined:
    Oct 3, 2016
    Posts:
    11
    How To Get Screen Size Width Height.
    or i need example code to get DisplayInfo pls.
     
  2. Spectrellian

    Spectrellian

    Joined:
    Mar 8, 2015
    Posts:
    25
    Remember that you can only use the DisplayInfo class when not testing in the editor. Here is a simple example how to get the screen witdth and height:

    Code (CSharp):
    1. var di = GetSingleton<DisplayInfo>();
    2.  
    3. var height = di.height;
    4. var width = di.width;
    It rarely returns wrong values for me but it seems to be a problem with the DisplayInfo class and my dynamic window size. But for testing and prototyping this works just fine :)