有时,单击由unity的新UI按钮创建的按钮后,该按钮将保持其突出显示状态。注意,Button脚本的Color Tint
设置为它的Transition
属性,并选中了Interactable
复选框。
我怎么才能解决这个问题?
发布于 2015-01-13 07:40:02
默认情况下,按钮的Navigation
属性设置为Automatic
,允许您使用箭头键导航按钮。
如果通过将Navigation
属性更改为None
来禁用此操作,则按钮将不会保持高亮显示。
发布于 2018-07-26 20:04:53
(除了可接受的答案之外,如果无法在上下文中将按钮的Navigation
属性设置为None
,则这是另一个答案。)
您还可以使用UnityEngine.EventSystem.SetSelectedGameObject
手动取消选择按钮。例如:
private void DeselectClickedButton(GameObject button)
{
if (EventSystem.current.currentSelectedGameObject == button)
{
EventSystem.current.SetSelectedGameObject(null);
}
}
https://gamedev.stackexchange.com/questions/92146
复制相似问题