void Update() { #if (UNITY_EDITOR) if (!EditorApplication.isPlaying && !EditorApplication.isPaused) { ScrollSetting(); } #endif if (SetScript == null) { return; } if (ScrollingCheck) { if (SetScript.MappingMode) { SetScript.EscBehavior(); } SetScript.InhibitMappingModeCheck = true; } else { SetScript.InhibitMappingModeCheck = false; } }
void Update() { if (StartSelectNullCheck) { StartSelectNullCheck = false; EventSystem.current.SetSelectedGameObject(null); } if (VerticalScrollScript != null) { ScrollIntoRatio = VerticalScrollScript.ScrollIntoRatio; ScrollIntoInertia = VerticalScrollScript.ScrollIntoInertia; } if (SetScript == null) { return; } if (SetScript.FirstSet || SetScript.MappingMode || SetScript.WindowSituation != 0) { OperateItemsSetNonInteractable(); if (SetScript.WindowSituation != 0 && SetScript.FirstSet != true) { ReturnSelectCheck = true; } } else { if (SetScript.CurrentryRestore) { OperateItemsSetSameSaveData(); } else { OperateItemsSetNormal(); } if (FirstSelectCheck) { EventSystem.current.SetSelectedGameObject(FirstSelectedMenuItem); FirstSelectCheck = false; ReturnSelectCheck = false; } else if (ReturnSelectCheck) { if (PrevSelectedGO != null) { EventSystem.current.SetSelectedGameObject(PrevSelectedGO); } else { EventSystem.current.SetSelectedGameObject(FirstSelectedMenuItem); } ReturnSelectCheck = false; } } CurrentSelectedGO = EventSystem.current.currentSelectedGameObject; //選択状態の項目の位置がスクロール窓の範囲外になったら常に選択項目が範囲内にあるようにする処理 if (VerticalScrollScript != null && VerticalScrollScript.UseVerticalScroll && CurrentSelectedGO != null) { bool ComparisonNotReadyCheck = false; if (CurrentSelectedGO.transform.parent.parent.gameObject == MenuItemsGO) { if (CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>()) { CurrentItemNum = CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>().MenuNum; if (CurrentItemNum == 0) { FromMostOverCheck = true; } else if (CurrentItemNum == (MenuItemButtonGOsAry.Length - 1)) { FromMostUnderCheck = true; } else { FromMostOverCheck = false; FromMostUnderCheck = false; } } else { ComparisonNotReadyCheck = true; } if (transform.parent.GetComponent <RectTransform>() != null && ComparisonNotReadyCheck != true) { transform.parent.GetComponent <RectTransform>().GetWorldCorners(ScrollRectCorners); } else { ComparisonNotReadyCheck = true; } if (CurrentSelectedGO.GetComponent <RectTransform>() != null && ComparisonNotReadyCheck != true) { CurrentSelectedGO.GetComponent <RectTransform>().GetWorldCorners(CurrentItemCorners); } else { ComparisonNotReadyCheck = true; } } else { ComparisonNotReadyCheck = true; FromMostOverCheck = false; FromMostUnderCheck = false; } if (ComparisonNotReadyCheck != true) { bool CurrentItemOverOutsideCheck = false; bool CurrentItemUnderOutsideCheck = false; if (CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>()) { CurrentItemOverOutsideCheck = CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>().ScrollOverOutsideCheck; CurrentItemUnderOutsideCheck = CurrentSelectedGO.transform.parent.GetComponent <UGUIMenuItem>().ScrollUnderOutsideCheck; } if (CurrentItemOverOutsideCheck || CurrentItemUnderOutsideCheck) { if (SetScript.MappingMode) { SetScript.EscBehavior(); } SetScript.InhibitMappingModeCheck = true; } if (CurrentItemOverOutsideCheck) { if (CurrentItemNum == 0 && FromMostUnderCheck) { //最下から最上へのループ的移動 FromMostUnderCheck = false; EndToEndCheck = true; if (IsInvoking("IntoRectFalse")) { CancelInvoke("IntoRectFalse"); } OverIntoRectCheck = true; UnderIntoRectCheck = false; } if (OverIntoRectCheck != true) { if (VerticalScrollScript.ScrollingNotify() != true) //スクロール中でないなら { if (IsInvoking("IntoRectFalse")) { CancelInvoke("IntoRectFalse"); } OverIntoRectCheck = true; UnderIntoRectCheck = false; } else { if (CurrentItemNum < (MenuItemButtonGOsAry.Length - 1)) { EventSystem.current.SetSelectedGameObject(MenuItemButtonGOsAry[CurrentItemNum + 1]); } } } } else if (CurrentItemUnderOutsideCheck) { if (CurrentItemNum == (MenuItemButtonGOsAry.Length - 1) && FromMostOverCheck) { //最上から最下へのループ的移動 FromMostOverCheck = false; EndToEndCheck = true; if (IsInvoking("IntoRectFalse")) { CancelInvoke("IntoRectFalse"); } OverIntoRectCheck = false; UnderIntoRectCheck = true; } if (UnderIntoRectCheck != true) { if (VerticalScrollScript.ScrollingNotify() != true) //スクロール中でないなら { if (IsInvoking("IntoRectFalse")) { CancelInvoke("IntoRectFalse"); } OverIntoRectCheck = false; UnderIntoRectCheck = true; } else { if (CurrentItemNum > 0) { EventSystem.current.SetSelectedGameObject(MenuItemButtonGOsAry[CurrentItemNum - 1]); } } } } else { if (VerticalScrollScript.ScrollingNotify()) { VerticalScrollScript.ScrollingCheckFalse(); if (OverIntoRectCheck || UnderIntoRectCheck) { Invoke("IntoRectFalse", ScrollIntoInertia); } } EndToEndCheck = false; } } if (OverIntoRectCheck || UnderIntoRectCheck) { Mapper.MoveDelayCall(); SetScript.InhibitMappingModeCheck = true; if (OverIntoRectCheck) { ScrollSpeedValue = (ScrollIntoRatio * 0.1f); } else if (UnderIntoRectCheck) { ScrollSpeedValue = -(ScrollIntoRatio * 0.1f); } if (EndToEndCheck) { if (MenuItemsGO.GetComponent <RectTransform>() != null && transform.parent.GetComponent <RectTransform>()) { ScrollSpeedValue = ScrollSpeedValue * (MenuItemsGO.GetComponent <RectTransform>().rect.height / transform.parent.GetComponent <RectTransform>().rect.height) * 1.5f; } else { ScrollSpeedValue = ScrollSpeedValue * 2; } } VerticalScrollScript.GetComponent <ScrollRect>().verticalNormalizedPosition = VerticalScrollScript.GetComponent <ScrollRect>().verticalNormalizedPosition + ScrollSpeedValue; } } if (SetScript.FirstSet) { //FirstSet中にカーソルオンでどこかが選択状態になった場合の挙動 if (CurrentSelectedGO != null) { PrevSelectedGO = CurrentSelectedGO; FirstSelectCheck = false; SetScript.FirstSet = false; } return; } //無関係な場所をクリックしても非選択状態にならないように if (SetScript.WindowSituation == 0) { if (CurrentSelectedGO != null) { if (CurrentSelectedGO != this.gameObject) { PrevSelectedGO = CurrentSelectedGO; } } else { if (PrevSelectedGO != null) { EventSystem.current.SetSelectedGameObject(PrevSelectedGO); } } } if (CurrentSelectedGO != this.gameObject) { //PrevSelectedMenuItem の更新 if (PrevSelectedGO != null && SetScript.OperateItemLine != true) { if (PrevSelectedGO.transform.parent.parent.gameObject.name == "InMapperMenuItems" && PrevSelectedGO.transform.parent.name.Length == 16 && PrevSelectedGO.transform.parent.name.IndexOf("MapperMenuItem") == 0) { PrevSelectedMenuItem = PrevSelectedGO; } } } else { if (SetScript.OperateItemLine) { if (PrevSelectedMenuItem == null) { if (FirstSelectedMenuItem != null) { PrevSelectedMenuItem = FirstSelectedMenuItem; } else { PrevSelectedMenuItem = transform.parent.Find("InMapperMenuItems/MapperMenuItem00/Button").gameObject; } } if (PrevSelectedMenuItem == null) { if (PrevSelectedGO != null) { EventSystem.current.SetSelectedGameObject(PrevSelectedGO); } } else { EventSystem.current.SetSelectedGameObject(PrevSelectedMenuItem); } } else { if (OperateItemsAry[0].GetComponent <Button>().interactable) { EventSystem.current.SetSelectedGameObject(OperateItemsAry[0]); } else { if (OperateItemsAry[2].GetComponent <Button>().interactable) { EventSystem.current.SetSelectedGameObject(OperateItemsAry[2]); } else { EventSystem.current.SetSelectedGameObject(PrevSelectedGO); } } } } if (SetScript.CurrentryRestore) { if (CurrentSelectedGO == OperateItemsAry[0] || CurrentSelectedGO == OperateItemsAry[1]) { EventSystem.current.SetSelectedGameObject(OperateItemsAry[2]); } } }
void Update() { SetScriptSearch(); SODataConfirm(); if (Input.GetKeyDown(KeyCode.Escape)) { if (SetScript != null && SetScript.UseEscDefinitedBehavior) { SetScript.EscBehavior(); } } jInputOnUp = jInputOnUp2p = jInputOnUp3p = jInputOnUp4p = false; jInputOnDown = jInputOnDown2p = jInputOnDown3p = jInputOnDown4p = false; jInputOnRight = jInputOnRight2p = jInputOnRight3p = jInputOnRight4p = false; jInputOnLeft = jInputOnLeft2p = jInputOnLeft3p = jInputOnLeft4p = false; UGUIOnSubmit = UGUIOnSubmit2p = UGUIOnSubmit3p = UGUIOnSubmit4p = false; UGUIOnCancel = UGUIOnCancel2p = UGUIOnCancel3p = UGUIOnCancel4p = false; float[,] PlayerAxesArys = new float[5, 4]; //[(int)player,(float)AxesValue] / player[0] is not used / AxesValue : 0=UpAxis, 1=DownAxis, 2=RightAxis, 3=LeftAxis if (SetScript != null && SetScript.transform.gameObject.activeSelf && PlayerNum > 1 && SetScript.PlayerNumSituation != true) { CollateJoystickNum = SetScript.JoystickNumNotify(); } else { CollateJoystickNum = 0; } if (UpMoveNumList.Count > 0) { for (int j = 1; j <= PlayerNum; j++) { //各PlayerのUpのAxisの最大値を配列に取る for (int i = 0; i < UpMoveNumList.Count; i++) { switch (j) { case 1: TempInputName = InputArray[UpMoveNumList[i]]; break; case 2: TempInputName = InputArray2p[UpMoveNumList[i]]; break; case 3: TempInputName = InputArray3p[UpMoveNumList[i]]; break; case 4: TempInputName = InputArray4p[UpMoveNumList[i]]; break; } if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } if (jInput.GetAxis(TempInputName) > PlayerAxesArys[j, 0]) { PlayerAxesArys[j, 0] = jInput.GetAxis(TempInputName); } } } } if (DownMoveNumList.Count > 0) { for (int j = 1; j <= PlayerNum; j++) { //各PlayerのDownのAxisの最大値を配列に取る for (int i = 0; i < DownMoveNumList.Count; i++) { switch (j) { case 1: TempInputName = InputArray[DownMoveNumList[i]]; break; case 2: TempInputName = InputArray2p[DownMoveNumList[i]]; break; case 3: TempInputName = InputArray3p[DownMoveNumList[i]]; break; case 4: TempInputName = InputArray4p[DownMoveNumList[i]]; break; } if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } if (jInput.GetAxis(TempInputName) > PlayerAxesArys[j, 1]) { PlayerAxesArys[j, 1] = jInput.GetAxis(TempInputName); } } } } if (RightMoveNumList.Count > 0) { for (int j = 1; j <= PlayerNum; j++) { //各PlayerのRightのAxisの最大値を配列に取る for (int i = 0; i < RightMoveNumList.Count; i++) { switch (j) { case 1: TempInputName = InputArray[RightMoveNumList[i]]; break; case 2: TempInputName = InputArray2p[RightMoveNumList[i]]; break; case 3: TempInputName = InputArray3p[RightMoveNumList[i]]; break; case 4: TempInputName = InputArray4p[RightMoveNumList[i]]; break; } if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } if (jInput.GetAxis(TempInputName) > PlayerAxesArys[j, 2]) { PlayerAxesArys[j, 2] = jInput.GetAxis(TempInputName); } } } } if (LeftMoveNumList.Count > 0) { for (int j = 1; j <= PlayerNum; j++) { //各PlayerのLeftのAxisの最大値を配列に取る for (int i = 0; i < LeftMoveNumList.Count; i++) { switch (j) { case 1: TempInputName = InputArray[LeftMoveNumList[i]]; break; case 2: TempInputName = InputArray2p[LeftMoveNumList[i]]; break; case 3: TempInputName = InputArray3p[LeftMoveNumList[i]]; break; case 4: TempInputName = InputArray4p[LeftMoveNumList[i]]; break; } if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } if (jInput.GetAxis(TempInputName) > PlayerAxesArys[j, 3]) { PlayerAxesArys[j, 3] = jInput.GetAxis(TempInputName); } } } } if (UGUICancelNumList.Count > 0) { BreakCheck = false; for (int j = 1; j <= PlayerNum; j++) { for (int i = 0; i < UGUICancelNumList.Count; i++) { switch (j) { case 1: TempInputName = InputArray[UGUICancelNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnCancel = true; BreakCheck = true; } break; case 2: TempInputName = InputArray2p[UGUICancelNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnCancel2p = true; BreakCheck = true; } break; case 3: TempInputName = InputArray3p[UGUICancelNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnCancel3p = true; BreakCheck = true; } break; case 4: TempInputName = InputArray4p[UGUICancelNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnCancel4p = true; BreakCheck = true; } break; } if (BreakCheck) { BreakCheck = false; break; } } } } if (UGUISubmitNumList.Count > 0) { BreakCheck = false; for (int j = 1; j <= PlayerNum; j++) { for (int i = 0; i < UGUISubmitNumList.Count; i++) { switch (j) { case 1: if (UGUIOnCancel) { BreakCheck = true; } else { TempInputName = InputArray[UGUISubmitNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnSubmit = true; BreakCheck = true; } } break; case 2: if (UGUIOnCancel2p) { BreakCheck = true; } else { TempInputName = InputArray2p[UGUISubmitNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnSubmit2p = true; BreakCheck = true; } } break; case 3: if (UGUIOnCancel3p) { BreakCheck = true; } else { TempInputName = InputArray3p[UGUISubmitNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnSubmit3p = true; BreakCheck = true; } } break; case 4: if (UGUIOnCancel4p) { BreakCheck = true; } else { TempInputName = InputArray4p[UGUISubmitNumList[i]]; if (jInput.GetKeyDown(TempInputName)) { if (CollateJoystickNum != 0 && TempInputName.IndexOf("Joystick") == 0) { if (CollateJoystickNum != Convert.ToInt32(TempInputName.Substring(8, 1))) { continue; } } UGUIOnSubmit4p = true; BreakCheck = true; } } break; } if (BreakCheck) { BreakCheck = false; break; } } } } if (EventSystem.current != null && EventSystem.current.currentInputModule != null) { UGUIInputModule = EventSystem.current.currentInputModule as StandaloneInputModule; m_InputActionsPerSecond = UGUIInputModule.inputActionsPerSecond; m_RepeatDelay = UGUIInputModule.repeatDelay; } else { m_InputActionsPerSecond = 7; m_RepeatDelay = 0.7f; } float ScaleTime = Time.unscaledTime; for (int i = 1; i <= PlayerNum; i++) { if (MoveDelayCallCheck) { PrevActionTimeAry[i] = ScaleTime; } if (ScaleTime < PrevActionTimeAry[i] + (1.0f / m_InputActionsPerSecond)) { AllowMoveCheckAry[i] = false; } else { AllowMoveCheckAry[i] = true; } } MoveDelayCallCheck = false; for (int k = 1; k <= PlayerNum; k++) { if (PlayerAxesArys[k, 0] < 0.35f && PlayerAxesArys[k, 1] < 0.35f && PlayerAxesArys[k, 2] < 0.35f && PlayerAxesArys[k, 3] < 0.35f) { PrevAxisIndexAry[k] = -1; continue; } else { int MaxAxisIndex = 0; for (int i = 0; i < 4; i++) { if (PlayerAxesArys[k, MaxAxisIndex] < PlayerAxesArys[k, i]) { MaxAxisIndex = i; } } if (PrevAxisIndexAry[k] != MaxAxisIndex) { AllowRepeatCheckAry[k] = true; RepeatActionTimeAry[k] = ScaleTime; } else { if (ScaleTime < RepeatActionTimeAry[k] + m_RepeatDelay) { AllowRepeatCheckAry[k] = false; } else { AllowRepeatCheckAry[k] = true; } } PrevAxisIndexAry[k] = MaxAxisIndex; if (AllowMoveCheckAry[k] && AllowRepeatCheckAry[k]) { PrevActionTimeAry[k] = ScaleTime; switch (MaxAxisIndex) { case 0: if (k == 1) { jInputOnUp = true; } else if (k == 2) { jInputOnUp2p = true; } else if (k == 3) { jInputOnUp3p = true; } else if (k == 4) { jInputOnUp4p = true; } break; case 1: if (k == 1) { jInputOnDown = true; } else if (k == 2) { jInputOnDown2p = true; } else if (k == 3) { jInputOnDown3p = true; } else if (k == 4) { jInputOnDown4p = true; } break; case 2: if (k == 1) { jInputOnRight = true; } else if (k == 2) { jInputOnRight2p = true; } else if (k == 3) { jInputOnRight3p = true; } else if (k == 4) { jInputOnRight4p = true; } break; case 3: if (k == 1) { jInputOnLeft = true; } else if (k == 2) { jInputOnLeft2p = true; } else if (k == 3) { jInputOnLeft3p = true; } else if (k == 4) { jInputOnLeft4p = true; } break; } } } } }