/// <summary> /// 创建时输入名字状态的手柄输入检测 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void CreateNameInputType_HandleUpdate(UIManager.KeyType keyType, Vector2 rockValue) { if (nowNameInputFocus == null && nameInputUIFocusPath) { nowNameInputFocus = nameInputUIFocusPath.GetFirstFocus(); if (nowNameInputFocus) { nowNameInputFocus.SetForcus(); } } if (nowNameInputFocus) { //判断键位 Action <UIFocusPath.MoveType> MoveFocusAction = (moveType) => { UIFocus next = nameInputUIFocusPath.GetNewNextFocus(nowNameInputFocus, moveType);// uiFocusPath.GetNextFocus(nowFocus, moveType, true); if (next) { nowNameInputFocus.LostForcus(); nowNameInputFocus = next; nowNameInputFocus.SetForcus(); } }; switch (keyType) { case UIManager.KeyType.A: if (nowNameInputFocus) { UIFocusButton uiFocusButton = nowNameInputFocus as UIFocusButton; UIFocusInputField uiFocusInputField = nowNameInputFocus as UIFocusInputField; if (uiFocusButton) { uiFocusButton.ClickThisButton(); } else if (uiFocusInputField) { uiFocusInputField.EnterInputField(); } } break; case UIManager.KeyType.LEFT: MoveFocusAction(UIFocusPath.MoveType.LEFT); break; case UIManager.KeyType.RIGHT: MoveFocusAction(UIFocusPath.MoveType.RIGHT); break; case UIManager.KeyType.UP: MoveFocusAction(UIFocusPath.MoveType.UP); break; case UIManager.KeyType.DOWN: MoveFocusAction(UIFocusPath.MoveType.DOWN); break; } } }
/// <summary> /// 输入名字的按钮点击时 /// </summary> /// <param name="uiFocus"></param> public void CreateNameInputButtonClick(UIFocus uiFocus) { if (uiFocus) { switch (uiFocus.Tag) { case "OK": { UIFocusInputField uiFocusInputField = nameInputUIFocusPath.GetFirstFocus <UIFocusInputField>(); if (uiFocusInputField) { InputField inputField = uiFocusInputField.GetComponent <InputField>(); if (inputField) { if (!string.IsNullOrEmpty(inputField.text)) { PlayerState playerState = DataCenter.Instance.GetEntity <PlayerState>(); playerState.PlayerName = inputField.text; //再次保存 DataCenter.Instance.Save(1, "存档", "默认存档"); //隐藏该面板显示进入面板 entranceType = EnumEntranceType.Transition; nameInputRect.gameObject.SetActive(false); StartCoroutine(CrossoverMaskImageAlpha(1, () => { createRect.gameObject.SetActive(false); enterRect.gameObject.SetActive(true); InitEnterRect(); StartCoroutine(CrossoverMaskImageAlpha(0, () => { entranceType = EnumEntranceType.Enter; })); })); } } } } break; case "Cancel": roleOfRaceRect.gameObject.SetActive(true); nameInputRect.gameObject.SetActive(false); entranceType = EnumEntranceType.Create_SelectRoleOfRace; InitCreateSelectRoleOfRace(); break; } } }