适配问题: 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; }
时间: 2024-11-06 07:32:15