I am trying to create a Pixelperfect GUI that will work across all resolutions. Practically fixed size seems to handle different resolutions easiest but without pixel perfect. You can work around this by increasing the UIRoot manualheight in fixed size mode as the resolution increases. Applying a scale factor to this for the different atlases then allows for have a larger pixel sized button for higher resolution textures. This keeps a fixed size output for each atlas across the target range and then allows for switching size when you have a new range / atlas.
A test script is included below. Putting this in Update() seems to work well in the editor when you resize the game window. Is this a valid way of doing things? I see there is a new Adjust by DPI setting, but I am unsure the differences with that and my method and how to simulate this without access to many different devices. Would it also work for all DPI's (or DPI ranges), or just a few key targeted ones?
void Start() {
int manualHeight;
if (Screen.height >= 1080) {
atlasRef.replacement = Resources.Load ("TestAtlas4x", typeof(UIAtlas)) as UIAtlas;
manualHeight = (int)Screen.height;
} else if (Screen.height >= 640) {
atlasRef.replacement = Resources.Load ("TestAtlas2x", typeof(UIAtlas)) as UIAtlas;
manualHeight = (int)(Screen.height * 2);
} else {
atlasRef.replacement = Resources.Load ("TestAtlas1x", typeof(UIAtlas)) as UIAtlas;
manualHeight = (int)(Screen.height * 4);
}
UIRoot root = this.gameObject.GetComponent<UIRoot> ();
if (root.scalingStyle != UIRoot.Scaling.FixedSize) {
root.scalingStyle = UIRoot.Scaling.FixedSize;
}
if (root.manualHeight != manualHeight) {
root.manualHeight = manualHeight;
}
}
Any help appreciated. Thanks