unity关闭方向键对于toggle按钮组的影响

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

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将为您提供在场景中设置的导航的可视化表示

窗口。见下文。

Scene window showing the visualized navigation connections

                      显示可视化导航连接的场景窗口

在上面的可视化模式中,箭头表示如何为控件集合作为一个组设置焦点更改。这意味着——对于每个单独的UI控件——如果用户在给定控件有焦点时按下箭头键,就可以看到下一个将获得焦点的UI控件。因此,在上面的例子中,如果“按钮”有焦点,用户按下右箭头键,第一个(左)垂直滑块将成为焦点。请注意,垂直滑块不能使用向上或向下键进行对焦,因为它们控制滑块的值。水平滑块和左右箭头键也是如此。(自我理解:焦点可以理解为toggle组中当前选中的按钮)

 

如上所示,想要避免方向键对于toggle按钮的选择影响,应该把navigation选项设置为none

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章