浏览代码

Preselect default button

/main
Ciro Continisio 4 年前
当前提交
7354551c
共有 2 个文件被更改,包括 19 次插入3 次删除
  1. 1
      UOP1_Project/Assets/Prefabs/Menu/DebugMenu.prefab
  2. 21
      UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs

1
UOP1_Project/Assets/Prefabs/Menu/DebugMenu.prefab


m_Script: {fileID: 11500000, guid: af38c0740d43a4f419a21ea970c9cf53, type: 3}
m_Name:
m_EditorClassIdentifier:
_defaultSelection: {fileID: 9071686869219419063}
_currentSelection: {fileID: 0}
_mouseSelection: {fileID: 0}
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}

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


using System;
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;

[SerializeField] private InputReader _inputReader;
[SerializeField] private GameObject _defaultSelection;
[SerializeField] private InputReader _inputReader;
StartCoroutine(SelectDefault());
}
private void OnDisable()

}
/// <summary>
/// Fired by keyboard and gamepad inputs. current selected UI element will be the ui Element that was selected
/// when the event was fired. The _currentSelection is updated later on, after the EventSystem moves to the
/// Highlights the default element
/// </summary>
private IEnumerator SelectDefault()
{
yield return new WaitForEndOfFrame(); // Necessary wait otherwise the highlight won't show up
if (_defaultSelection != null)
EventSystem.current.SetSelectedGameObject(_defaultSelection);
}
/// <summary>
/// Fired by keyboard and gamepad inputs. Current selected UI element will be the ui Element that was selected
/// when the event was fired. The _currentSelection is updated later on, after the EventSystem moves to the
/// desired UI element, the UI element will call into UpdateSelection()
/// </summary>
private void HandleMoveSelection()

正在加载...
取消
保存