Created
August 4, 2012 00:37
-
-
Save boj/3253068 to your computer and use it in GitHub Desktop.
Unity3d Aspect Ratio Check
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
using UnityEngine; | |
using System.Collections; | |
public class GameConfig : MonoBehaviour { | |
public static bool isFourThreeAspect() { | |
int factor = gcd(Screen.width, Screen.height); | |
int wFactor = Screen.width / factor; | |
int hFactor = Screen.height / factor; | |
if (wFactor == 3 && hFactor == 4) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
public static bool isSixteenNineAspect() { | |
int factor = gcd(Screen.width, Screen.height); | |
int wFactor = Screen.width / factor; | |
int hFactor = Screen.height / factor; | |
if (wFactor == 9 && hFactor == 16) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
public static int gcd(int a, int b) { | |
return (b == 0) ? a : gcd (b, a % b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment