Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. 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:
    38
    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:
    319
    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:
    38
    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?