UIRoot:
public class UIRoot : MonoBehaviour { static public List<UIRoot> list = new List<UIRoot>(); public enum Scaling { PixelPerfect, // 像素不变,大小变 FixedSize, // 大小不变,像素变 FixedSizeOnMobiles, } public Scaling scalingStyle = Scaling.PixelPerfect; public int manualHeight = 720; public int minimumHeight = 320; public int maximumHeight = 1536; public bool adjustByDPI = false; public bool shrinkPortraitUI = false; public int activeHeight { get { if (scalingStyle == Scaling.FixedSize) return manualHeight; #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY if (scalingStyle == Scaling.FixedSizeOnMobiles) return manualHeight; #endif Vector2 screen = NGUITools.screenSize; float aspect = screen.x / screen.y; if (screen.y < minimumHeight) { screen.y = minimumHeight; screen.x = screen.y * aspect; } else if (screen.y > maximumHeight) { screen.y = maximumHeight; screen.x = screen.y * aspect; } // Portrait mode uses the maximum of width or height to shrink the UI int height = Mathf.RoundToInt((shrinkPortraitUI && screen.y > screen.x) ? screen.y / aspect : screen.y); // Adjust the final value by the DPI setting return adjustByDPI ? NGUIMath.AdjustByDPI(height) : height; } } static public void Broadcast (string funcName) { #if UNITY_EDITOR if (Application.isPlaying) #endif { for (int i = 0, imax = list.Count; i < imax; ++i) { UIRoot root = list[i]; if (root != null) root.BroadcastMessage(funcName, SendMessageOptions.DontRequireReceiver); } } } }
1.这个组件以静态的方式管理了所有的组件在一个list里面UIRoot,并且可以使用Broadcast方法进行消息广播。
2.这个组件是UI的根节点,它主要是通过缩放自己的方式来控制整个UI的大小,两种方式:PixelPerfect 和 FixedSize。
3.如果adjustByDPI = true,则高度为屏幕当前高度。反之,为manualHeight。
http://blog.csdn.net/asd237241291/article/details/8126619 这是一篇关于自适应屏幕大小的文章,我个人觉得没必要搞的这么复杂。一般使用FixedSize即可。
整个UIRoot最核心的功能就是整体缩放,所以必须把这块理解清楚。
activeHeight:1.类型为FixedSize时,它的值为manualHeight。2.adjustByDPI = true时,它为当前屏幕的高度。3.否则,activeHeight = 屏幕高度 的值会夹在一个范围内[minimum,maximum],如果超出这个范围,屏幕的宽度会等比缩放。
FixedSize:这种模式下,activeHeight的值跟屏幕本身的高度是无关的,你可以理解为固定大小。
pixelperfect:这种模式下有两种选择,一种是没有范围约束直接获取屏幕的高度,另一种是有范围约束。
可以肯定的是,无论是那种模式,U3D都不希望出现高宽非等比例缩放的情况,因为这样的话界面就会变形。
UIOrthoCamera:
public class UIOrthoCamera : MonoBehaviour { Camera mCam; Transform mTrans; void Start () { mCam = camera; mTrans = transform; mCam.orthographic = true; } void Update () { float y0 = mCam.rect.yMin * Screen.height; float y1 = mCam.rect.yMax * Screen.height; float size = (y1 - y0) * 0.5f * mTrans.lossyScale.y; if (!Mathf.Approximately(mCam.orthographicSize, size)) mCam.orthographicSize = size; } }
很多文章都只是说用了这玩意就不能用UIRoot,可以简单的理解为它是PixelPerfect 适应方案,并且采用的是屏幕的高度,而不是人为设置的高度。
UICamera:
Event Type:四种类型,决定相机以什么样的方式碰撞检测,也可以理解为相机只检测什么样的控件。
public enum EventType : int { World_3D, // Perform a Physics.Raycast and sort by distance to the point that was hit. UI_3D, // Perform a Physics.Raycast and sort by widget depth. World_2D, // Perform a Physics2D.OverlapPoint UI_2D, // Physics2D.OverlapPoint then sort by widget depth }
Event Mask:决定触发什么类型的事件,可以是所有类型。
allow multi touch:勾选,就表示支持多点触控。
sticky tooltip:是否使用tooltip,在NGUI里面有个UITooltip专门用来处理tip这个需求的。
tooltip Delay:这个地方设置tip停留的时间
http://blog.csdn.net/tinyhum3d/article/details/9069639 这篇文章详细介绍NGUI里面制作tip相关的东西。
UICamera主要是负责事件的,其他的还有一些跟事件相关的选项
相关推荐
NGUI的核心组件UICamera2
NGUI Next-Gen UI v3.11.2 (u5)
- NEW: Added UICamera.first referencing the active NGUI event system. - FIX: Alpha should now work as expected with Linear lighting. - FIX: UICamera.isOverUI should now work properly for all types of ...
NGUI Next-Gen UI 3.12.1(基于unity)NGUI Next-Gen UI 3.12.1(基于unity)
NGUI是严格遵循KISS原则并用C#编写的Unity(适用于专业版和免费版)插件,提供强大的UI系统和事件通知框架。其代码简洁,多数类少于200行代码。这意味着程序员可以很容易地扩展NGUI的功能或调节已有功能。对所有其他...
与其他UI插件相比,NGUI Next-Gen UI具有高效的性能和优秀的渲染效果,可以帮助开发者快速构建出美观、流畅的用户界面。 在NGUI Next-Gen UI中,开发者可以使用多种UI元素,包括文本、按钮、滚动视图、进度条等。...
NGUI is a powerful UI system and event notification framework for Unity (both Pro and Free) written in C# that closely follows the KISS principle. It features clean code and simple, minimalistic ...
NGUI Next-Gen UI v3.12.1.unitypackage NGUI Next-Gen UI v3.11.0 (u5).unitypackage NGUI Next-Gen UI 3.9.0b.unitypackage NGUI Next-Gen UI v3.7.6.unitypackage NGUI Next-Gen UI v3.7.0 (Aug 16, 2014).unity...
NGUI Next-Gen UI v2021.11.30.unitypackage
最新版本的NGUI插件NGUI Next-Gen UI
NGUI Next-Gen UI 3.6.0.unitypackage NGUI Next-Gen UI 3.12.1(u5.6.5).unitypackage NGUI Next-Gen UI 2019.3.0.unitypackage NGUI Next-Gen UI v2018.3.0.unitypackage NGUI Next-Gen UI v2018.3.0c(u2018.3.0)....
NGUI Next-Gen UI v3.11.4 一款unity开发时候要用到的界面插件 高版本哦3.11
Unity3D NGUI Next-Gen UI 2.2.2
NGUI资源,包含:NGUI Next-Gen UI 3.12.1(u5.6.5)|NGUI Next-Gen UI 2019.3.0|NGUI Next-Gen UI v3.11.0b (u5.4.3)|NGUI Next-Gen UI v2018.3.0|NGUI Next-Gen UI v2018.3.0c(u2018.3.0)|NGUI Next-Gen UI v2018.3....
NGUI Next-Gen UI v3.9.2.7z ngui最新版本 3.9.2
NGUI Next-Gen UI v3.12.1.unitypackage
NGUI Next-Gen UI v3.9.8.unitypackage
NGUI Next-Gen UI v3.7.7(最新完整版)
最新版unity3d扩展插件:NGUI Next-Gen UI3.6.0 运行Unity3D,解压后此压缩包,在菜单Assets中选择自定义导入。...NGUI是一款功能强大的UI系统和事件通知框架。所见即所得的集成编辑器,支持所有平台。