-
-
Save kirillrybin/762c80d277c199656def to your computer and use it in GitHub Desktop.
NGUI Unity3d : Getting Screen size via http://www.zedia.net/2013/ngui-unity3d-getting-screen-size/
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; | |
public class DisplaySize{ | |
protected static DisplaySize _instance; | |
public static DisplaySize instance{ | |
get { | |
if (_instance == null){ | |
_instance = new DisplaySize(); | |
} | |
return _instance; | |
} | |
} | |
public GameObject gameObject; | |
public float width; | |
public float height; | |
public void CalculateSize(){ | |
UIRoot mRoot = NGUITools.FindInParents<UIRoot>(gameObject); | |
float ratio = (float)mRoot.activeHeight / Screen.height; | |
width = Mathf.Ceil(Screen.width * ratio); | |
height = Mathf.Ceil(Screen.height * ratio); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment