NGUI等比缩放

    /// <summary>
    ///  UI 等比缩放
    /// </summary>
    static private void AdaptiveUI()
    {
        int ManualWidth = 960;
        int ManualHeight = 540;
        UIRoot uiRoot = GameObject.FindObjectOfType<UIRoot>();
        if (uiRoot != null)
        {
            if (System.Convert.ToSingle(Screen.height) / Screen.width > System.Convert.ToSingle(ManualHeight) / ManualWidth)
                uiRoot.manualHeight = Mathf.RoundToInt(System.Convert.ToSingle(ManualWidth) / Screen.width * Screen.height);
            else
                uiRoot.manualHeight = ManualHeight;
        }
    }

posted @ 2015-02-27 10:35  尚菜  阅读(618)  评论(0编辑  收藏  举报