void Update() { if (Input.GetMouseButtonDown(2)) { middleClickDownScreenPos = Input.mousePosition; } else if (!Input.GetMouseButton(2) && middleClickDownScreenPos.HasValue) { middleClickDownScreenPos = null; Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); } if (Input.GetMouseButtonUp(0) && editor.currentState == ChartEditor.State.Editor) { cancel = false; } if (Services.IsInDropDown) { cancel = true; } // Update timer text if (timePosition) { bool audioLoaded = false; foreach (var stream in editor.currentSongAudio.bassAudioStreams) { if (AudioManager.StreamIsValid(stream)) { audioLoaded = true; } } if (!audioLoaded)//editor.currentSong.songAudioLoaded) { timePosition.color = Color.red; timePosition.text = "No audio"; } else { timePosition.color = Color.white; timePosition.text = Utility.timeConvertion(TickFunctions.WorldYPositionToTime(strikeLine.position.y)); } } if (MSChartEditorInput.GetGroupInputDown(arrowKeyShortcutGroup)) { arrowMoveTimer = 0; } else if (MSChartEditorInput.GetGroupInput(arrowKeyShortcutGroup)) { arrowMoveTimer += Time.deltaTime; } else { arrowMoveTimer = 0; } }
// Update is called once per frame void LateUpdate() { if (!MSChartEditorInput.GetInput(MSChartEditorInputActions.SelectAllSection) || editor.currentSong.sections.Count <= 0) { sectionHighlightRealOriginIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos); sectionHighlightCurrentIndex = sectionHighlightRealOriginIndex; } if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { lastMouseDownPos = Input.mousePosition; } if (editor.currentState == ChartEditor.State.Editor) { Vector2 middleClickDragPercentageDelta = GetMiddleClickDragPercentageDelta(); if (scrollDelta == 0 && focused) { scrollDelta = Input.mouseScrollDelta.y; } if (middleClickDragPercentageDelta != Vector2.zero) { float sign = Mathf.Sign(middleClickDragPercentageDelta.y); Texture2D cursorTexture = sign >= 0 ? dragCursorPositive : dragCursorNegative; Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.ForceSoftware); scrollDelta = middleClickDragPercentageDelta.y * c_middleClickMouseDragSensitivity; } if (Services.IsInDropDown) { scrollDelta = 0; } // Position changes scroll bar value if (scrollDelta != 0 || transform.position != prevPos || Services.HasScreenResized) { if (MSChartEditorInput.GetInput(MSChartEditorInputActions.SectionJumpMouseScroll) && editor.currentSong.sections.Count > 0) { SectionJump(scrollDelta); RefreshSectionHighlight(); } else { // Mouse scroll movement mouseScrollMovePosition.x = transform.position.x; mouseScrollMovePosition.y = transform.position.y + (scrollDelta * c_mouseScrollSensitivity); mouseScrollMovePosition.z = transform.position.z; transform.position = mouseScrollMovePosition; explicitChartPos = null; } if (transform.position.y < initPos.y) { transform.position = initPos; } if (Services.HasScreenResized) { StartCoroutine(resolutionChangePosHold()); } UpdateTimelineHandleBasedPos(); } else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SectionJumpPositive) && editor.currentSong.sections.Count > 0) { SectionJump(1); UpdateTimelineHandleBasedPos(); RefreshSectionHighlight(); } else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SectionJumpNegative) && editor.currentSong.sections.Count > 0) { SectionJump(-1); UpdateTimelineHandleBasedPos(); RefreshSectionHighlight(); } else if (MSChartEditorInput.GetGroupInput(arrowKeyShortcutGroup)) { // Arrow key controls uint currentPos; if (explicitChartPos != null) { currentPos = (uint)explicitChartPos; } else { currentPos = editor.currentTickPos; } if (arrowMoveTimer == 0 || (arrowMoveTimer > ARROW_INIT_DELAY_TIME && Time.realtimeSinceStartup > lastMoveTime + ARROW_HOLD_MOVE_ITERATION_TIME)) { uint snappedPos = currentPos; // Navigate to snapped pos ahead or behind if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepPositive)) { snappedPos = Snapable.ChartIncrementStep(currentPos, GameSettings.step, editor.currentSong); } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepNegative)) { snappedPos = Snapable.ChartDecrementStep(currentPos, GameSettings.step, editor.currentSong); } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasurePositive)) { snappedPos = Snapable.TickToSnappedTick(currentPos + (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong); } // Page Down else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasureNegative)) { snappedPos = Snapable.TickToSnappedTick(currentPos - (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong); } if (editor.currentSong.TickToTime(snappedPos, editor.currentSong.resolution) <= editor.currentSongLength) { SetPosition(snappedPos); } lastMoveTime = Time.realtimeSinceStartup; } UpdateTimelineHandleBasedPos(); } // else check mouse range else if (globals.services.InToolArea && (Input.GetMouseButton(0) || Input.GetMouseButton(1)) && Input.mousePosition != lastMouseDownPos) { if (UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == null && Input.mousePosition.y > Camera.main.WorldToScreenPoint(editor.mouseYMaxLimit.position).y) { // Autoscroll, dragging out notes/sustains etc transform.position = new Vector3(transform.position.x, transform.position.y + autoscrollSpeed * Time.deltaTime, transform.position.z); UpdateTimelineHandleBasedPos(); } else { UpdatePosBasedTimelineHandle(); } } // Scroll bar value changes position else { UpdatePosBasedTimelineHandle(); } } else if (editor.currentState == ChartEditor.State.Playing) { PlayingMovement(); // Update timeline handle UpdateTimelineHandleBasedPos(); if (timeline.handlePos >= 1) { editor.Stop(); } } if (editor.currentState != ChartEditor.State.Playing) { lastUpdatedRealTime = Time.realtimeSinceStartup; } prevPos = transform.position; }