-
-
Save gksen/1743fe25807131c6e66ae5280e24d63a to your computer and use it in GitHub Desktop.
Unity get scale factor (Android-like style for DP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Awake() { | |
var refDp = scaler.referenceResolution.y; | |
var realDp = Screen.height * 160 / Screen.dpi; | |
var factor = refDp / realDp; | |
Debug.Log ("RefDP: " + refDp + " realDP: " + realDp + " factor: " + factor); | |
if (factor < 1) { | |
factor = (factor + 1) / 2f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment