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

hd and sd in 2d

Discussion in '2D' started by Tatanan, Jun 13, 2014.

  1. Tatanan

    Tatanan

    Joined:
    Jun 9, 2014
    Posts:
    9
    Hello.
    I come from Cocos2d and with Cocos2d you had 2 (or more folder) for your png files for high and low resolution. I don't know how to and can't find any information about handling sereral resolutions with Unity (for 2D).

    How should I proceed?

    Thank you.
     
  2. cbothra

    cbothra

    Joined:
    Mar 14, 2014
    Posts:
    125
    Hi Tatanan,

    For multiple resolution support you need to adjust the orthographic size of the camera in unity, which will scale the app as per the device resolution. Besides that if you want to load the png files from the two different folders hd and sd then you need to first detect the resolution of the current running device and based on that you can pick the files.

    Also note that the hd and the sd folders shall reside in the folder named "Resources" inside Assets directory :)

    Besides that please checkout the unity script reference for the Camera and the Resources.
     
  3. Tatanan

    Tatanan

    Joined:
    Jun 9, 2014
    Posts:
    9
    Thank you for the reply.
    It's not that "I want to load pngs from different folders". I actually don't know what I want, since I don't know which is the best approach for multiresolution in Unity. In all example in the site I only see one set of files, so I don't even know if I have to create pngs twice and just let Unity to handle it.
     
  4. cbothra

    cbothra

    Joined:
    Mar 14, 2014
    Posts:
    125
    You are absolutely right that people create the one set of art only and adjust the camera accordingly which will scale the app in aspect ratio based on whatever the current resolution of the device is. However I just let you know about the possibility of having the two folders hd and sd :). Even I use only single set of the art.
     
  5. Tatanan

    Tatanan

    Joined:
    Jun 9, 2014
    Posts:
    9
    Thank you again.

    And using only one single set of the art is worse for performance? Is such case, I guess that I should desing for HD, shouldn't I?

    In such case, would HD textures/sprites (2D) will be processed by SD devices? Or Unity automatically convert HD pngs to SD pngs to improve performance?

    I hope I am explaining well :)
     
  6. Kurius

    Kurius

    Joined:
    Sep 29, 2013
    Posts:
    412
    You should design your game around a base resolution of 960x640 (aka iPhone 4 resolution). Unfortunately many of the crappy low end Android phones will crash if any sprite (including background sprites) or atlases are larger than 1024x1024. So that resolution I chose will keep you safe in this regard. Let's call this a "mid resolution" quality. The sprites for this resolution are your @2x sprites. You will want to also include a duplicate set of "low resolution sprites", half the size, so 480x320 (aka iPhone 3GS resolution). These are your @1x sprites. These are useful on small crappy Android phones that do not have enough RAM nor enough Virtual Memory to handle lots of big sprites simultaneously. Finally if you want (I choose not to), you can target "high resolution", so 1920x1080 (official definition of 1080HD) quality. These would be your @4x sprites. I personally feel that my mid resolution looks fine on high def devices.

    Now, how do you implement all of this? Well these forums have some suggestions on how to custom code the sprite management in your game for different resolutions. Alternatively, you can buy the 2Dtoolkit plugin and it will handle all of this automatically for you….
    http://www.unikronsoftware.com/2dto...ced/platform_specific_sprite_collections.html
     
  7. Tatanan

    Tatanan

    Joined:
    Jun 9, 2014
    Posts:
    9
    Thank you Kurius.
    If I always pick @4x sprites, so large sprite fo 1920x1080 and then I open the game with a very bad Android low resolution device, I would move the camera to fit my sprites.
    My doubt is: Will the device store those textures (pngs) and then consume a lot of resources or Unity resizes the textures to load smaller pngs/textures?
    Thank you again.
     
  8. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hi,

    What is the point about scaling the camera size ?
    For my understanding, and it's more a question than a affirmation, according to the screen size (ratio and resolution) Unity scales up or down the assets in order to always have the same things visible in the screen, at least in the vertical edge of the screen, and only crop in the horizontal edge. I came to this conclusion by playing with the screen aspect ratio in the Game view.
    So there is no need to manually change the Camera size, Unity seems to do it by itself, is that right ? What matter is the assets resolution in order to fit with the screen resolution, I guess.
     
  9. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    The point of having separate HD and SD folders is for performance. I honestly see very little performance gain unless we're talking about mobile devices (I don't know anything about their performance).

    You're talking HDD space (SD consumes less, obviously, but having both consumes MORE than just HD), RAM usage (SD uses less ram, HD uses more), and I assume maybe rendering (I am skeptical as to anything that has trouble rendering HD graphic sets but no trouble rendering SD.)

    Honestly, I would have two separate projects entirely.

    One downloadable "SD" version, and one downloadable "HD" version. This saves precious HDD space on mobile devices, it allows the consumer to choose which they want (and downgrade if necessary). It also simplifies the process for the developer. Instead of having an options menu to pick which version, you literally just change out the image folder with identical images at lower resolution. It would be as easy as batching a process in photoshop. Literally a few clicks.


    All the trouble thinking "How does it work?" or "What should I code to allow the option or scale properly?" Instead, you simply make your game with HD, see what it looks like swapping with SD, and then continue on in HD until the game is completed.


    I say this because as a consumer, I would be annoyed having to store all the HDD space for the graphics set I never use. Especially if those graphics consumed a significant amount of space on my mobile device. I don't have much, after all. A single video or a few camera shots and *poof* I'm already begging for megabytes.