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. Dismiss Notice

Change only camera resolution and keep UI at native resolution

Discussion in 'Editor & General Support' started by tomes11, Feb 28, 2016.

  1. tomes11

    tomes11

    Joined:
    Apr 22, 2014
    Posts:
    8
    The problem is, that Screen.SetResolution changes the whole screen. On Android it becomes a huge problem, as my smaller UI elements are unreadable. A good example would be GTA (Android). Wheneve you change it the UI remains at native resolution. So, is there any way to do it in 4.x? For performance reasons i cant go to 5.x .
     
  2. Shykeas

    Shykeas

    Joined:
    Apr 11, 2015
    Posts:
    145
    =-UNTESTED-=

    I've never used 4. I've only used 3 and 5. However, in FIVE there is a RectTransform component for UI objects. I was TOLD they were introduced in 4. So not sure. Anywho, if this DOES exist in four inside the image attached you'll see these triangles. When introducing a new UI Object into the scene you just drag the edges of those around and it'll lock it's self on those parts of the screen. Try putting all sides at the corner and then putting the object at that corner and change the resolution and then magic!

    .... If, unfortunately, this doesn't exist in 4...... Well I tried. D':
     

    Attached Files:

  3. tomes11

    tomes11

    Joined:
    Apr 22, 2014
    Posts:
    8
    That should not work. The UI elements will still be scaled down to unreadable resolution. For example: Native resolution is 1280x720, and you have a button with 100x100 pixels. Now when resolution changes, the buttons resolution changes too! What i need is something like this: we have a smaller camera and upscale it. That way the new 960x540 camera would scaled up to 1280x720, and the button remains at 100x100 (because its independent of the camera object)
     
  4. Shykeas

    Shykeas

    Joined:
    Apr 11, 2015
    Posts:
    145
    Actually, no. If I am reading your question correctly, the only time the UI element is scaled is if you change the distance from any of the four triangles. If all four triangles are still touching, but just placed elsewhere on the canvas, it won't scale at all! It'll only move. (This is why you are able to get all four triangles and change their distance apart form eachother. So if can be scaled through the distance. But if they are all touching, no matter the resolution it'll stay the same size and resolution.)
     
  5. Shykeas

    Shykeas

    Joined:
    Apr 11, 2015
    Posts:
    145
    In the image, do you see that those four triangles don't touch? changing the resolution will change the size according to that square the triangles are making. (By that rectangle, it'll be scaled quite a nasty bit)

    Also, mind that "Keep aspect ratio" option. So it won't get scaled as a rectangle. And as I see you DON'T want this, just make sure all of them are touching and place them anywhere on the canvas.
     

    Attached Files:

  6. tomes11

    tomes11

    Joined:
    Apr 22, 2014
    Posts:
    8
    You misunderstood this. I'm not touching the UI. As i said in the previous post, I want to scale the camera (or something like this). So it has nothing to do with the UI, as the whole Canvas remains at native resolution! I'm looking for a way to scale the camera.
     
  7. jtsmith1287

    jtsmith1287

    Joined:
    Aug 3, 2014
    Posts:
    787
    Each canvas has a canvas scaler component by default. You can use pixel density or a reference resolution to work with. I prefer reference resolution since a lot of mobile devices have massive pixel density, and it can cause fonts to get super tiny. Using a reference resolution will keep your UI roughly the same size no matter what. With that set, there should be zero harm in changing your camera size. Come to think of it, you shouldn't change the camera size... you should be changing either the orthographic size or the perspective, and neither of those thing will effect a screen space UI, only worldspace. Now I'm curious what it is you're doing...
     
  8. tomes11

    tomes11

    Joined:
    Apr 22, 2014
    Posts:
    8
    Here's two screenshots from GTA:VC to illustrate the problem:
    Native resolution:
    Screenshot_2016-03-02-07-04-49.png
    And the lower resolution:
    Screenshot_2016-03-02-07-05-13.png
    Notice how the health, date etc. are crystal clear why the gameplay is at a lower resolution. This is because we are still at full screen but the rendering is at lower resolution of the camera and its scaled up.
     
  9. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    You can render into a rendertexture of a size of your choice and blit the small image upscaled to the full screen.
     
  10. Shykeas

    Shykeas

    Joined:
    Apr 11, 2015
    Posts:
    145
    Yeah, this is all you, fffMalzbier.
     
  11. tomes11

    tomes11

    Joined:
    Apr 22, 2014
    Posts:
    8
    Rendertexture is not an option as I use the free version of unity4. (can't go to 5 for performance reasons)

    EDIT: Just tested it in unity 5. It's worse than the default camera in fps. Dont use it!
    Any other solution?
     
    Last edited: Mar 2, 2016
  12. Shykeas

    Shykeas

    Joined:
    Apr 11, 2015
    Posts:
    145
    Um.. Well, I do think turning off Mip Maps in the UI Texture keeps it crystal clear no matter the resolution.
    And as for the camera... I really don't know. I never had this problem. :( Sorry, bleh.
     
  13. BugiGames

    BugiGames

    Joined:
    Oct 20, 2020
    Posts:
    8
    @tomes11 did you find fix on your problem ?
     
  14. AshwinTheGammer

    AshwinTheGammer

    Joined:
    Sep 23, 2016
    Posts:
    68
    did you?
     
  15. BugiGames

    BugiGames

    Joined:
    Oct 20, 2020
    Posts:
    8
    sorry for late, I find some solutions, like in URP using render scale component, and in simple project
    Code (CSharp):
    1. Screen.SetResolution(yourPhoneRes/1.7f, yourPhoneRes/1.7f, true);
    some code like this, but you need to reset it, and also it affect on UI, but render scale doesn't affect in UI