using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; public class GameMenuView : MonoBehaviour { public Button[] funcItemButtons; private int funcItemButtonIndex = -1; void UpdateFuncItemButtonIndex(int deltaValue) { if (funcItemButtonIndex == -1) { funcItemButtonIndex = 0; return; } funcItemButtonIndex += deltaValue; while (funcItemButtonIndex < 0) funcItemButtonIndex += funcItemButtons.Length; funcItemButtonIndex %= funcItemButtons.Length; } void Update() { if (Input.GetKeyDown(KeyCode.UpArrow)) { UpdateFuncItemButtonIndex(-1); SetSelectable(funcItemButtons[funcItemButtonIndex]); AudioMgr.ins.PlayBtn(); } if (Input.GetKeyDown(KeyCode.DownArrow)) { UpdateFuncItemButtonIndex(1); SetSelectable(funcItemButtons[funcItemButtonIndex]); AudioMgr.ins.PlayBtn(); } if (Input.GetKeyDown(KeyCode.JoystickButton0) || Input.GetKeyDown(KeyCode.Return)) { if (funcItemButtonIndex == -1) DuckHunter.TextSmartBowTip.Show("尚未选择按钮"); else OnClikc_Confirm(); } if (Input.GetKeyDown(KeyCode.Escape)) { funcItemButtonIndex = -1; SetSelectable(null); AudioMgr.ins.PlayBtn(); } } #region 选项功能 Selectable _targetSelectable; Vector3 _targetlocalScale; Color _targetColor; Selectable.Transition _btnTransition; void SetSelectable(Selectable selectable) { if (selectable == _targetSelectable) return; ResumeTarget(); if (!selectable) { _targetSelectable = null; return; } Button btn = selectable.GetComponent