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.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    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:
    34
    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:
    34
    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?