Search Unity

  1. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice

Get the Screen width and Screen Height

Discussion in 'Project Tiny' started by Rangerz132, Mar 25, 2021.

  1. Rangerz132

    Rangerz132

    Joined:
    Feb 3, 2019
    Posts:
    18
    Hello! I would like to get the value in pourcentage of my input position according to the screen.

    I'm currently able to get the exact position but I'm not able to get access to the Screen width and Screen height for my calculations. Is there a way to get access to these values?

    Thanks! :)
     
  2. AbdulAlgharbi

    AbdulAlgharbi

    Unity Technologies

    Joined:
    Jul 27, 2018
    Posts:
    318
    Hi,
    Use the DisplayInfo Singleton
    Code (CSharp):
    1.  
    2. var di = GetSingleton<DisplayInfo>();
    3. var w = di.ScreenWidth;
     
  3. Rangerz132

    Rangerz132

    Joined:
    Feb 3, 2019
    Posts:
    18
    Thanks Abdul! However, it seems that the ScreenHeight (0,0) is at the bottom left. Is there a way to get that (0,0) at top left?
     
unityunity