- Home /
Any asset to help me achieve "Resolution specific sprites", how?
Hi,
I want to load platform specific and resolution specific textures/sprites, for example when my game runs on a iPod touch 4G, it would load assets that are specific to that size and not larger ones so it would not waste memory and also appear pixel perfect and not anti aliased.
In another engine I could add postfixes to my sprite names and it would load them automatically and am interested to know how to do it in Unity.
I'm interested to either buy suggested assets or do it manually.
Thanks.
Answer by Hoeloe · Oct 01, 2013 at 01:01 AM
In fact, it's not that hard to do it in Unity. You would use the Resources.Load
method to load assets into your game. What you can do is to wrap it up in a function, say, LoadAsset(string filename)
, which would do essentially the same thing as Resources.Load
. However, what it will do is an extra check. First, it will analyse the resolution and platform of the system it is running on. Having done that, and determined the correct sizes, it will simply add a postfix to the input string (say, "_4G" for the iPod Touch 4G). Then, it would call Resources.Load
on the newly modified string. This will search for the file: "FILENAME_4G", which will get the correct asset for the platform. This method of wrapping up functions and checks that are to be used regularly is a common and useful one, and is generally good practice.
As long as you don't put things into your scene, and as long as you don't call Resources.Load, the assets will never be put into memory, so you should be safe with this method.