Hi, I want to ensure that the user gets the correct image resolutions based on their phone's specifications. In other words, if their smart phone has a high ppi and a high resolution, I want them to have the best images. I don't want a user to have better graphics if they can't display them. This is to save space and processor time. How do I do this in Unity?
ie. old iPhones will have lower resolution images ie. new iPhones will have medium/high quality images
I understand that I can use Platform Dependent Compilation to make sure that some scripts only run on certain platforms, like this:
#if UNITY_IPHONE // some code that will be compiled only for iPhones #endif
Can this code be extended to only include the neccesary image files?
ONE POSSIBLE SOLUTION: I create the highest quality image files (high ppi). When the program runs for the first time, I scale these images down to the appropriate PPI and replace the originals with the scaled down version. So, the initial download will be slightly larger but after the first run the entire size of the program will be reduced slightly. Is this the way to do it? Is there a better way? I don't want to use asset bundles.
Answer by Koen-Matthijs
Mar 22 at 09:49 PM
We tackled this using AssetBundle Variants. If you want to know how it works, check out this link : https://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
4 People are following this question.
Exclude Resources on web platform
How to use an Image(PNG) and GUISkin inside a dll ?
Problems changing from standalone to iOS
Compiler error in the Lerpz tutorial at startup
Issue on moving using CharacterController