I use a script to switch atlas.
void iosChange()
{
if(Application.platform == RuntimePlatform.IPhonePlayer)
{
if(Screen.currentResolution.width==480)
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas480x320;
}
}
if(Screen.currentResolution.width==1136)
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas1136x640;
}
}
if(Screen.currentResolution.width==960)
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas960x640;
}
}
if(Screen.currentResolution.width==1024)
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas1024x768;
}
}
}
}
void androidChange()
{
if(Application.platform == RuntimePlatform.Android)
{
if(Screen.currentResolution.width<1024)
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas800x480;
}
}
if(Screen.currentResolution.width>=1024&&Screen.currentResolution.width<1280)
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas1024x768;
}
}
if(Screen.currentResolution.width>=1280)
{
if(Screen.currentResolution.height>=800)
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas1280x800;
}
}
else
{
for(int i=0;i<pairs.Length;i++)
{
pairs[i].atlasRef.replacement = pairs[i].atlas1280x720;
}
}
}
}
}
I use the device to test the effect and found the result not as I expected.for example,my sprite real size is 161x38 when resolution is 800x480,194x51 size when resolution is 960x640.When I set my editor resolution is 960x640,and add a sprite in editor,and in inspector,it's scale is auto set 194x51,and I deploy the app on iphone,everything is right.
But I switch the platform and deploy the app on android device.the sprite size is not change,still 194x51.I have change the atlas ,isn't it?To solve this problem,I must select the sprite in editor and click correction --"Make Pixel-Perfect",and it's scale is auto set 161x38.Obviously,So much resolution I can not so each set.
I don't know where the problem.Help me,please!!