码迷,mamicode.com
首页 > 其他好文 > 详细

NGUI适配问题

时间:2016-05-27 15:04:28      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:ngui     适配   

适配问题:

ui原有的适配也只是绑了上下左右的锚点

更该ngui的设置,只能完成按高等比缩放

那么只能自己动手更改了,ngui控制缩放的功能在UIroot下的activeHeight属性

在UIRoot下做如下修改
//设置是的宽高
   public const int ManualWidth = 1920;
   public const int ManualHeight = 1080;
 
  public int activeHeight
   {
       get
       {
           AdaptiveUI();
           //不需要缩放的范围
           if (manualHeight < 950 || manualHeight > 1100)
           {
               return manualHeight;
           }
 
           //原先的正常逻辑
       }
   }
 
   private void AdaptiveUI()
   {
       if (System.Convert.ToSingle(Screen.height) / Screen.width > System.Convert.ToSingle(ManualHeight) / ManualWidth)
           manualHeight = Mathf.CeilToInt(System.Convert.ToSingle(ManualWidth) / Screen.width * Screen.height);
       else
           manualHeight = ManualHeight;
   }


本文出自 “Unity_3D技术探讨” 博客,谢绝转载!

NGUI适配问题

标签:ngui     适配   

原文地址:http://myselfdream.blog.51cto.com/9944020/1783707

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!