浏览代码

removed call to base.onenter in CC button to simplify selection logic

/main
kgc00 4 年前
当前提交
bd56bebf
共有 2 个文件被更改,包括 0 次插入18 次删除
  1. 2
      UOP1_Project/Assets/Scripts/Menu/CC_Button.cs
  2. 16
      UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs

2
UOP1_Project/Assets/Scripts/Menu/CC_Button.cs


public override void OnPointerEnter(PointerEventData eventData)
{
_menuSelectionHandler.HandleMouseEnter(gameObject);
base.OnPointerEnter(eventData);
base.OnPointerExit(eventData);
}
public override void OnSelect(BaseEventData eventData)

16
UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs


// Handle case where no UI element is selected because mouse left selectable bounds
if (EventSystem.current.currentSelectedGameObject == null)
EventSystem.current.SetSelectedGameObject(_currentSelection);
// occurs when mouse is on top of some button, and we hit a gamepad or keyboard key to change the selection
var mouseIsOverSelectionStart = _mouseSelection == _currentSelection;
if (mouseIsOverSelectionStart)
{
// fire pointer exit event because we don't want the button to be in the 'highlighted' state
ExecuteEvents.Execute(EventSystem.current.currentSelectedGameObject,
new PointerEventData(EventSystem.current),
ExecuteEvents.pointerExitHandler);
// update the selection
EventSystem.current.SetSelectedGameObject(_currentSelection);
// the event we fired earlier clears _mouseSelection, reset it here because our cursor is still over the button
_mouseSelection = _currentSelection;
}
}
private void HandleMoveCursor()

正在加载...
取消
保存