Skip to main content
Including link to example script
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373
  • 3D objects and 2D sprites positioned in your scene's worldspace will not move, scale or change their worldspace transformations no matter what happens to the display screen/window.

    • BUT: These objects are viewed through a Camera, and the camera's view is mapped to the screen. That mapping will change as the screen/window size changes.

      BUT: These objects are viewed through a Camera, and the camera's view is mapped to the screen. That mapping will change as the screen/window size changes.

      By default, Unity will keep the camera's vertical FoV or orthographic height the same, meaning that you'll see the same portion of your game world from the top to bottom of the screen. So if your objects were 60 pixels tall on a screen 1080 pixels in height, they'll be 40 pixels tall when displayed on a 720-pixel-high screen. The objects didn't move or shrink in your scene, so all your gameplay metrics and physics will work identically: they're just being displayed on fewer pixels.

      The width of the camera's view is, by default, allowed to grow or shrink to match the aspect ratio of the screen. So a player on a wider screen will see more of your scene to the left and right. If you haven't placed any objects there, they'll see blank space, because Unity doesn't know what you might want to put there instead - you'll have to tell it.

    By default, Unity  will keep the camera's vertical FoV or orthographic height the same, meaning that you'll see the same portion of your game world vertically. So if your objects were 60 pixels tall on a screen 1080 pixels in height, they'll be 40 pixels tall when displayed on a 720-pixel-high screen. The objects didn't move or shrink in your scene, they're just being displayed on fewer pixels.
    

    The width of the camera's view is, by default, allowed to grow or shrink to match the aspect ratio of the screen. So a player on a wider screen will see more of your scene to the left and right. If you haven't placed any objects there, they'll see blank space, because Unity doesn't know what you might want to put there instead - you'll have to tell it.

  • UI objects inside a Canvas element that's set to Screenspace - Camera or Screenspace - Overlay will be repositioned / sized according to their anchors when the dimensions of the containing canvas's viewport change.

    This lets you, say, make a UI button that's always in the bottom-right corner, no matter how tall or wide the window/screen is.

    The canvas and UI components expose a number of controls for you to decide exactly how you want this scaling to happen - whether you want to preserve sizes proportional to the width or height, or preserve the native pixel size of the elements, etc.

  • 3D objects and 2D sprites positioned in your scene's worldspace will not move, scale or change their worldspace transformations no matter what happens to the display screen/window.

    • BUT: These objects are viewed through a Camera, and the camera's view is mapped to the screen. That mapping will change as the screen/window size changes.
    By default, Unity  will keep the camera's vertical FoV or orthographic height the same, meaning that you'll see the same portion of your game world vertically. So if your objects were 60 pixels tall on a screen 1080 pixels in height, they'll be 40 pixels tall when displayed on a 720-pixel-high screen. The objects didn't move or shrink in your scene, they're just being displayed on fewer pixels.
    

    The width of the camera's view is, by default, allowed to grow or shrink to match the aspect ratio of the screen. So a player on a wider screen will see more of your scene to the left and right. If you haven't placed any objects there, they'll see blank space, because Unity doesn't know what you might want to put there instead - you'll have to tell it.

  • UI objects inside a Canvas element that's set to Screenspace - Camera or Screenspace - Overlay will be repositioned / sized according to their anchors when the dimensions of the containing canvas's viewport change.

    This lets you, say, make a UI button that's always in the bottom-right corner, no matter how tall or wide the window/screen is.

    The canvas and UI components expose a number of controls for you to decide exactly how you want this scaling to happen - whether you want to preserve sizes proportional to the width or height, or preserve the native pixel size of the elements, etc.

  • Do you want to match the width of the screen instead of the height? Put a script on the camera that adjusts the height or FoV properties to match the aspect ratio of the screen/window.

  • Do you want to spread your objects wider / cluster them more narrowly depending on the width? Update your spawning script to scale its spread by the screen/window's aspect ratio.

  • 3D objects and 2D sprites positioned in your scene's worldspace will not move, scale or change their worldspace transformations no matter what happens to the display screen/window.

    • BUT: These objects are viewed through a Camera, and the camera's view is mapped to the screen. That mapping will change as the screen/window size changes.

      By default, Unity will keep the camera's vertical FoV or orthographic height the same, meaning that you'll see the same portion of your game world from the top to bottom of the screen. So if your objects were 60 pixels tall on a screen 1080 pixels in height, they'll be 40 pixels tall when displayed on a 720-pixel-high screen. The objects didn't move or shrink in your scene, so all your gameplay metrics and physics will work identically: they're just being displayed on fewer pixels.

      The width of the camera's view is, by default, allowed to grow or shrink to match the aspect ratio of the screen. So a player on a wider screen will see more of your scene to the left and right. If you haven't placed any objects there, they'll see blank space, because Unity doesn't know what you might want to put there instead - you'll have to tell it.

  • UI objects inside a Canvas element that's set to Screenspace - Camera or Screenspace - Overlay will be repositioned / sized according to their anchors when the dimensions of the containing canvas's viewport change.

    This lets you, say, make a UI button that's always in the bottom-right corner, no matter how tall or wide the window/screen is.

    The canvas and UI components expose a number of controls for you to decide exactly how you want this scaling to happen - whether you want to preserve sizes proportional to the width or height, or preserve the native pixel size of the elements, etc.

Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

This depends on how you've authored the objects.

  • 3D objects and 2D sprites positioned in your scene's worldspace will not move, scale or change their worldspace transformations no matter what happens to the display screen/window.

    • BUT: These objects are viewed through a Camera, and the camera's view is mapped to the screen. That mapping will change as the screen/window size changes.
    By default, Unity  will keep the camera's vertical FoV or orthographic height the same, meaning that you'll see the same portion of your game world vertically. So if your objects were 60 pixels tall on a screen 1080 pixels in height, they'll be 40 pixels tall when displayed on a 720-pixel-high screen. The objects didn't move or shrink in your scene, they're just being displayed on fewer pixels.
    

    The width of the camera's view is, by default, allowed to grow or shrink to match the aspect ratio of the screen. So a player on a wider screen will see more of your scene to the left and right. If you haven't placed any objects there, they'll see blank space, because Unity doesn't know what you might want to put there instead - you'll have to tell it.

  • UI objects inside a Canvas element that's set to Screenspace - Camera or Screenspace - Overlay will be repositioned / sized according to their anchors when the dimensions of the containing canvas's viewport change.

    This lets you, say, make a UI button that's always in the bottom-right corner, no matter how tall or wide the window/screen is.

    The canvas and UI components expose a number of controls for you to decide exactly how you want this scaling to happen - whether you want to preserve sizes proportional to the width or height, or preserve the native pixel size of the elements, etc.

If you like the scaling behaviour described above, you're done. If not, then you'll need to define what "proper" scaling behaviour is for your game. Some examples:

  • Do you want to match the width of the screen instead of the height? Put a script on the camera that adjusts the height or FoV properties to match the aspect ratio of the screen/window.

  • Do you want to spread your objects wider / cluster them more narrowly depending on the width? Update your spawning script to scale its spread by the screen/window's aspect ratio.