好吧,在做完Demo之后,才发现UIStretch这个组件,这个组件说穿了就是用来控制widget的缩放的。
回想我之前做的Demo,为了让弹出的NGUI对话框变成模式对话框(即它关闭之前,其他UI不能响应),我在UI中嵌入了一层覆盖全屏的透明Sprite,用于捕捉点击事件,这个全屏的我当时是在Sprite上挂了个脚本,在Start的时候,获取Screen的Width和Height,来设置Sprite的长宽像素(而且这样做还是错误的,详见上面那个NGUI屏幕适应的博客),其实用UIStretch的话就完全不用了。
先来看Stretch组件的几个参数和官方解释:
Camera | uiCamera = null |
Camera used to determine the anchor bounds. Set automatically if none was specified. More... |
|
GameObject | container = null |
Object used to determine the container's bounds. Overwrites the camera-based anchoring if the value was specified. More... |
|
Style |