Search Unity

Question Device Simulator Question

Discussion in 'Editor & General Support' started by mstewart52178, Mar 28, 2023.

  1. mstewart52178

    mstewart52178

    Joined:
    Feb 8, 2022
    Posts:
    19
    Do I need to make a script with a switch case to determine the SystemInfo.deviceModel and adjust the Cam view and UI accordingly, or is there a solution already in the Device Simulator package that I missed? Hoping that there is because the idea of making cases for the 70+ devices listed in the package, in addition to the multitudes of devices that are not listed; does not sound appealing. I suppose I can display a canvas with instructions to adjust the Cam size until the edges line up with some indicators, but I would rather not annoy potential users with that being the first thing presented to them. Any other solutions or ideas?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Can't you just use the game resolution, aspect ratio, safe area, and a little bit of algebra to determine your camera size? That list isn't going to be exhaustive anyway.
     
  3. mstewart52178

    mstewart52178

    Joined:
    Feb 8, 2022
    Posts:
    19
    Oh, duh. Forgot about the resolution in settings. Thank you. So something like the following line should be enough?

    Screen.SetResolution(Display.main.renderingWidth, Display.main.renderingHeight, true);
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    No, you're not trying to change the game resolution here. The problem is your camera zoom (orthographicSize for an orthographic camera).

    You need to get the aspect ratio of the screen and zoom it (change orthographic size) such that the desired amount of the game world is shown on the screen. There's a little algrebra involved in this, centered around the aspect ratio of the screen (width/height), the height of the camera (orthographic height is 1/2 the visible vertical area. If orthographicHeight is 10, You will be able to see 20 units of vertical space in the camera view.)