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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

resize the screen depending on the aspect ration

Discussion in 'Scripting' started by nepomuko, Jun 11, 2015.

  1. nepomuko

    nepomuko

    Joined:
    Mar 17, 2014
    Posts:
    24
    hey, i'm working on a small mobile game and i'd like to have a script that automatically resizes my screen on the aspect ratio in order to have similar looks on different mobile phone versions.

    for example the x size should be fixed at 320...
    what the script should do is:

    1. get the Y size
    2. get the X size
    3. divide the Y by X
    4. multiply the result by 320.

    usually i'm working with playmaker, my coding skills are limited.. but in couldn't get it to work on iphone, at least the part of getting the screen size.
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    The Screen class will have all the information you need and will be how you set the resolution.
     
    Mycroft likes this.
  3. nepomuko

    nepomuko

    Joined:
    Mar 17, 2014
    Posts:
    24
    but screen.width and screen.height ist getting the size of the window depending on the resolution set in the game and not of the device, am i right? how do i actually get the width and height of the device?