void RefreshSectionHighlight()
    {
        if (!ShortcutInput.GetInput(Shortcut.SelectAllSection))
        {
            return;
        }

        int  currentSectionIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos);
        bool changed             = currentSectionIndex != sectionHighlightCurrentIndex;

        editor.currentSelectedObject = null;
        sectionHighlightCurrentIndex = currentSectionIndex;

        for (int i = 0; Mathf.Abs(i) <= Mathf.Abs(sectionHighlightOffset); i -= (int)Mathf.Sign(sectionHighlightOffset))
        {
            globals.AddHighlightCurrentSection(i);
        }
    }
    void RefreshSectionHighlight()
    {
        if (!MSChartEditorInput.GetInput(MSChartEditorInputActions.SelectAllSection))
        {
            return;
        }

        int  currentSectionIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos);
        bool changed             = currentSectionIndex != sectionHighlightCurrentIndex;

        editor.selectedObjectsManager.currentSelectedObject = null;
        sectionHighlightCurrentIndex = currentSectionIndex;

        for (int i = 0; Mathf.Abs(i) <= Mathf.Abs(sectionHighlightOffset); i -= (int)Mathf.Sign(sectionHighlightOffset))
        {
            editor.selectedObjectsManager.AddHighlightCurrentSection(Globals.viewMode, i);
        }
    }
    // Update is called once per frame
    void LateUpdate()
    {
        if (!ShortcutInput.GetInput(Shortcut.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 (Globals.applicationMode == Globals.ApplicationMode.Editor)
        {
            if (scrollDelta == 0 && focused)
            {
                scrollDelta = Input.mouseScrollDelta.y;
            }

            if (Services.IsInDropDown)
            {
                scrollDelta = 0;
            }

            // Position changes scroll bar value
            if (scrollDelta != 0 || transform.position != prevPos || Services.HasScreenResized)
            {
                if (ShortcutInput.GetInput(Shortcut.SectionJumpMouseScroll) && editor.currentSong.sections.Count > 0)
                {
                    SectionJump(scrollDelta);
                    RefreshSectionHighlight();
                }
                else
                {
                    // Mouse scroll movement
                    mouseScrollMovePosition.x = transform.position.x;
                    mouseScrollMovePosition.y = transform.position.y + (scrollDelta * 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 (ShortcutInput.GetInputDown(Shortcut.SectionJumpPositive) && editor.currentSong.sections.Count > 0)
            {
                SectionJump(1);
                UpdateTimelineHandleBasedPos();
                RefreshSectionHighlight();
            }
            else if (ShortcutInput.GetInputDown(Shortcut.SectionJumpNegative) && editor.currentSong.sections.Count > 0)
            {
                SectionJump(-1);
                UpdateTimelineHandleBasedPos();
                RefreshSectionHighlight();
            }
            else if (ShortcutInput.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 (ShortcutInput.GetInput(Shortcut.MoveStepPositive))
                    {
                        snappedPos = Snapable.ChartIncrementStep(currentPos, GameSettings.step, editor.currentSong.resolution);
                    }
                    else if (ShortcutInput.GetInput(Shortcut.MoveStepNegative))
                    {
                        snappedPos = Snapable.ChartDecrementStep(currentPos, GameSettings.step, editor.currentSong.resolution);
                    }
                    else if (ShortcutInput.GetInput(Shortcut.MoveMeasurePositive))
                    {
                        snappedPos = Snapable.TickToSnappedTick(currentPos + (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong.resolution);
                    }
                    // Page Down
                    else if (ShortcutInput.GetInput(Shortcut.MoveMeasureNegative))
                    {
                        snappedPos = Snapable.TickToSnappedTick(currentPos - (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong.resolution);
                    }

                    if (editor.currentSong.TickToTime(snappedPos, editor.currentSong.resolution) <= editor.currentSong.length)
                    {
                        SetPosition(snappedPos);
                    }

                    lastMoveTime = Time.realtimeSinceStartup;
                }

                UpdateTimelineHandleBasedPos();
            }
            // else check mouse range
            else if (Toolpane.mouseDownInArea && (globals.services.InToolArea && (Input.GetMouseButton(0) || Input.GetMouseButton(1)) && Input.mousePosition != lastMouseDownPos))
            {
                if (!Toolpane.menuCancel &&
                    UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == null &&
                    Input.mousePosition.y > Camera.main.WorldToScreenPoint(editor.mouseYMaxLimit.position).y)
                {
                    // Autoscroll
                    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 (Globals.applicationMode == Globals.ApplicationMode.Playing)
        {
            PlayingMovement();

            // Update timeline handle
            UpdateTimelineHandleBasedPos();

            if (timeline.handlePos >= 1)
            {
                editor.Stop();
            }
        }

        if (Globals.applicationMode != Globals.ApplicationMode.Playing)
        {
            lastUpdatedRealTime = Time.realtimeSinceStartup;
        }

        prevPos = transform.position;
    }
    // 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, Globals.gameSettings.step, editor.currentSong);

                        if (snappedPos == currentPos)       // This can happen on really weird custom step values
                        {
                            ++snappedPos;
                        }
                    }
                    else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepNegative))
                    {
                        snappedPos = Snapable.ChartDecrementStep(currentPos, Globals.gameSettings.step, editor.currentSong);

                        if (snappedPos == currentPos && snappedPos > 0)     // This can happen on really weird custom step values
                        {
                            --snappedPos;
                        }
                    }
                    else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasurePositive))
                    {
                        snappedPos = Snapable.TickToSnappedTick(currentPos + (uint)(editor.currentSong.resolution * 4), Globals.gameSettings.step, editor.currentSong);
                    }
                    // Page Down
                    else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasureNegative))
                    {
                        snappedPos = Snapable.TickToSnappedTick(currentPos - (uint)(editor.currentSong.resolution * 4), Globals.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;
    }