Are we on a high density screen (e.g. Retina display)?
Namespace: NarayanaGames.CommonAssembly: Assembly-CSharp-firstpass (in Assembly-CSharp-firstpass.dll) Version: 0.0.0.0
public static bool IsHighDensityDisplay { get; }public static bool IsHighDensityDisplay { get; }
Starting with
Unity 3.5 this uses Screen.dpi (which only works on mobile, though!) and
also does a sanity check for the actual screen resolution to prevent low
resolution but higher density Android devices to get the Retina stuff
(which will usually break screen designs that assume "iPhone is minimum").
As Unity 3.4.2 doesn't support Screen.dpi, we use a very simple heuristic
based on screen resolution that will only reliably catch iPhone 4, 4S, 5
and iPad 3 (and Sharp IS03), and not so reliably (haven't tested) will
also catch Galaxy Nexus, LG Optimus LTE, Sony Xperia S, Galaxy Note.
As this heuristic is based on screen resolutions, you might get high
density if some vendor chose to provide a display with 960x640 or
2048x1536 or 1136x640 even though it isn't high density. The Android
heuristic also checks against device names. If this fails for you,
please let me know the precise details and I'll fix it; you find my
contact information on
narayana-games.net.
We could also use the classes recommended by Android (LDPI, MDPI, HDPI, XHDPI)
but that would make everything much more complex without adding significant
benefit. To learn more on screen densities see
Designing (and converting) for multiple mobile densities and
Supporting Multiple Screens