unity官方中對於toggle.navigation屬性的解釋如下:
鏈接:https://docs.unity3d.com/Manual/script-SelectableNavigation.html
Navigation Options
Property: | Function: |
---|---|
Navigation | The Navigation options refers to how the navigation of UI elements in play mode will be controlled. |
None | No keyboard navigation. Also ensures that it does not receive focus from clicking/tapping on it. |
Horizontal | Navigates Horizontally. |
Vertical | Navigates Vertically. |
Automatic | Automatic Navigation. |
Explicit | In this mode you can explicitly specify where the control navigates to for different arrow keys. |
Visualize | Selecting Visualize gives you a visual representation of the navigation you have set up in the scene window. See below. |
Scene window showing the visualized navigation connections
In the above visualization mode, the arrows indicate how the change of focus is set up for the collection of controls as a group. That means - for each individual UI control - you can see which UI control will get focus next, if the user presses an arrow key when the given control has focus. So in the example shown above, If the “button” has focus and the user presses the right arrow key, the first (left-hand) vertical slider will then become focused. Note that the vertical sliders can’t be focused-away-from using up or down keys, because they control the value of the slider. The same is true of the horizontal sliders and the left/right arrow keys.
自己翻譯了一下:
Navigation Options
Property: | Function: |
---|---|
Navigation |
導航選項指的是UI的導航方式 元素在播放模式將被控制。 |
None | 沒有鍵盤導航。還可以確保它不會因爲點擊/輕擊而獲得焦點。 |
Horizontal | 橫向導航 |
Vertical | 縱向導航 |
Automatic | 自動導航 |
Explicit | 在此模式下,可以顯式指定控件導航到不同箭頭鍵的位置。 |
Visualize |
選擇Visualize將爲您提供在場景中設置的導航的可視化表示 窗口。見下文。 |
顯示可視化導航連接的場景窗口
在上面的可視化模式中,箭頭表示如何爲控件集合作爲一個組設置焦點更改。這意味着——對於每個單獨的UI控件——如果用戶在給定控件有焦點時按下箭頭鍵,就可以看到下一個將獲得焦點的UI控件。因此,在上面的例子中,如果“按鈕”有焦點,用戶按下右箭頭鍵,第一個(左)垂直滑塊將成爲焦點。請注意,垂直滑塊不能使用向上或向下鍵進行對焦,因爲它們控制滑塊的值。水平滑塊和左右箭頭鍵也是如此。(自我理解:焦點可以理解爲toggle組中當前選中的按鈕)
如上所示,想要避免方向鍵對於toggle按鈕的選擇影響,應該把navigation選項設置爲none