UGUI_UGUI组件属性
?
Canvas
Canvas,Render Mode一共有三種模式。
?
?
?
?
?
?
?
Canvas Scaler
為UGUI在處理自適應
?
UI Scale Mode :Scale With Screen Size 表示以寬度為標準縮放。
補充: Canvas Scaler 選擇 Scale With Screen Size, Screen Match Mode 選擇 Match Width Or Height,比例設為1,即只和高度進行適配;
?
深度最小最先繪制,深度最大最前顯示。
?
?
3DCamera的自適應
?
創建UIForward,UI特效,要在UICamera的前面顯示。
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | using UnityEngine; using System.Collections; using UnityEngine.UI; public class CameraScale : MonoBehaviour { ? ? ????void Start () { ????????int ManualWidth = 960; ????????int ManualHeight = 640; ????????int manualHeight; ????????if (System.Convert.ToSingle(Screen.height) / Screen.width > System.Convert.ToSingle(ManualHeight) / ManualWidth) ????????????manualHeight = Mathf.RoundToInt(System.Convert.ToSingle(ManualWidth) / Screen.width * Screen.height); ????????else ????????????manualHeight = ManualHeight; ????????Camera camera = GetComponent<Camera>(); ????????float scale =System.Convert.ToSingle(manualHeight / 640f); ????????camera.fieldOfView*= scale; ????} } |
?
記得增加一個UIForward 的層, 這樣如果想在UI的前面添加特效 直接把它的特效的Layer設置成UIForward即可。
?
?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的UGUI_UGUI组件属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UGUI_LayoutGroup布局
- 下一篇: UGUI_UI子节点在Canvas的2D