Exemplo n.º 1
0
    protected GeneralDragEvent CreateGeneralDragEventStart(PointerEventData eventData)
    {
        float xDragStartInPixels = eventData.pressPosition.x;
        float yDragStartInPixels = eventData.pressPosition.y;
        float xDistanceInPixels  = 0;
        float yDistanceInPixels  = 0;

        List <RaycastResult> raycastResults      = new List <RaycastResult>();
        PointerEventData     eventDataForRaycast = new PointerEventData(EventSystem.current);

        eventDataForRaycast.position = eventData.pressPosition;
        graphicRaycaster.Raycast(eventDataForRaycast, raycastResults);

        RectTransformUtility.ScreenPointToLocalPointInRectangle(targetRectTransform,
                                                                eventData.pressPosition,
                                                                eventData.pressEventCamera,
                                                                out Vector2 localPoint);

        float widthInPixels       = targetRectTransform.rect.width;
        float heightInPixels      = targetRectTransform.rect.height;
        float xDragStartInPercent = (localPoint.x + (widthInPixels / 2)) / widthInPixels;
        float yDragStartInPercent = (localPoint.y + (heightInPixels / 2)) / heightInPixels;

        float xDistanceInPercent = 0;
        float yDistanceInPercent = 0;

        GeneralDragEvent result = new GeneralDragEvent(new Vector2(xDragStartInPixels, yDragStartInPixels),
                                                       new Vector2(xDragStartInPercent, yDragStartInPercent),
                                                       new Vector2(xDistanceInPixels, yDistanceInPixels),
                                                       new Vector2(xDistanceInPercent, yDistanceInPercent),
                                                       raycastResults,
                                                       eventData.button);

        return(result);
    }
Exemplo n.º 2
0
    public NoteAreaDragEvent(GeneralDragEvent generalDragEvent,
                             int midiNoteDragStart, int midiNoteDistance,
                             int positionInSongInMillisDragStart, int millisDistance,
                             int positionInSongInBeatsDragStart, int beatDistance)
    {
        GeneralDragEvent = generalDragEvent;

        MidiNoteDragStart = midiNoteDragStart;
        MidiNoteDistance  = midiNoteDistance;

        PositionInSongInMillisDragStart = positionInSongInMillisDragStart;
        MillisDistance = millisDistance;

        PositionInSongInBeatsDragStart = positionInSongInBeatsDragStart;
        BeatDistance = beatDistance;
    }
Exemplo n.º 3
0
    protected GeneralDragEvent CreateGeneralDragEvent(PointerEventData eventData, GeneralDragEvent dragStartEvent)
    {
        float xDistanceInPixels = eventData.position.x - dragStartEvent.StartPositionInPixels.x;
        float yDistanceInPixels = eventData.position.y - dragStartEvent.StartPositionInPixels.y;

        float widthInPixels      = targetRectTransform.rect.width;
        float heightInPixels     = targetRectTransform.rect.height;
        float xDistanceInPercent = xDistanceInPixels / widthInPixels;
        float yDistanceInPercent = yDistanceInPixels / heightInPixels;

        GeneralDragEvent result = new GeneralDragEvent(dragStartEvent.StartPositionInPixels,
                                                       dragStartEvent.StartPositionInPercent,
                                                       new Vector2(xDistanceInPixels, yDistanceInPixels),
                                                       new Vector2(xDistanceInPercent, yDistanceInPercent),
                                                       dragStartEvent.RaycastResultsDragStart,
                                                       dragStartEvent.InputButton);

        return(result);
    }
Exemplo n.º 4
0
    protected override NoteAreaDragEvent CreateDragEvent(PointerEventData eventData, NoteAreaDragEvent dragStartEvent)
    {
        GeneralDragEvent generalDragEvent = CreateGeneralDragEvent(eventData, dragStartEvent.GeneralDragEvent);

        int midiNoteDragStart = dragStartEvent.MidiNoteDragStart;
        int midiNoteDistance  = (int)(generalDragEvent.DistanceInPercent.y * noteArea.ViewportHeight);

        int positionInSongInMillisDragStart = dragStartEvent.PositionInSongInMillisDragStart;
        int millisDistance = (int)(generalDragEvent.DistanceInPercent.x * noteArea.ViewportWidth);

        int positionInSongInBeatsDragStart = dragStartEvent.PositionInSongInBeatsDragStart;
        int beatDistance = (int)(generalDragEvent.DistanceInPercent.x * noteArea.ViewportWidthInBeats);

        NoteAreaDragEvent result = new NoteAreaDragEvent(generalDragEvent,
                                                         midiNoteDragStart, midiNoteDistance,
                                                         positionInSongInMillisDragStart, millisDistance,
                                                         positionInSongInBeatsDragStart, beatDistance);

        return(result);
    }
Exemplo n.º 5
0
    protected override NoteAreaDragEvent CreateDragEventStart(PointerEventData eventData)
    {
        GeneralDragEvent generalDragEvent = CreateGeneralDragEventStart(eventData);

        int midiNoteDragStart = (int)(noteArea.ViewportY + generalDragEvent.StartPositionInPercent.y * noteArea.ViewportHeight);
        int midiNoteDistance  = 0;

        int positionInSongInMillisDragStart = (int)(noteArea.ViewportX + generalDragEvent.StartPositionInPercent.x * noteArea.ViewportWidth);
        int millisDistance = 0;

        int positionInSongInBeatsDragStart = (int)(noteArea.MinBeatInViewport + generalDragEvent.StartPositionInPercent.x * noteArea.ViewportWidthInBeats);
        int beatDistance = 0;

        NoteAreaDragEvent result = new NoteAreaDragEvent(generalDragEvent,
                                                         midiNoteDragStart, midiNoteDistance,
                                                         positionInSongInMillisDragStart, millisDistance,
                                                         positionInSongInBeatsDragStart, beatDistance);

        return(result);
    }
Exemplo n.º 6
0
    protected override NoteAreaDragEvent CreateDragEvent(DragControlPointerEvent eventData, NoteAreaDragEvent dragStartEvent)
    {
        GeneralDragEvent generalDragEvent = CreateGeneralDragEvent(eventData, dragStartEvent.GeneralDragEvent);

        int midiNoteDragStart = dragStartEvent.MidiNoteDragStart;
        int midiNoteDistance  = (int)Mathf.Round(generalDragEvent.LocalCoordinateInPercent.Distance.y * noteAreaControl.ViewportHeight);

        int positionInSongInMillisDragStart = dragStartEvent.PositionInSongInMillisDragStart;
        int millisDistance = (int)Mathf.Round(generalDragEvent.LocalCoordinateInPercent.Distance.x * noteAreaControl.ViewportWidth);

        int positionInSongInBeatsDragStart = dragStartEvent.PositionInSongInBeatsDragStart;
        int beatDistance = (int)Mathf.Round(generalDragEvent.LocalCoordinateInPercent.Distance.x * noteAreaControl.ViewportWidthInBeats);

        NoteAreaDragEvent result = new(generalDragEvent,
                                       midiNoteDragStart, midiNoteDistance,
                                       positionInSongInMillisDragStart, millisDistance,
                                       positionInSongInBeatsDragStart, beatDistance);

        return(result);
    }
Exemplo n.º 7
0
    protected override NoteAreaDragEvent CreateDragEventStart(DragControlPointerEvent eventData)
    {
        GeneralDragEvent generalDragEvent = CreateGeneralDragEventStart(eventData);

        int midiNoteDragStart = noteAreaControl.ScreenPixelPositionToMidiNote(generalDragEvent.ScreenCoordinateInPixels.StartPosition.y);
        int midiNoteDistance  = 0;

        int positionInSongInMillisDragStart = noteAreaControl.ScreenPixelPositionToMillis(generalDragEvent.ScreenCoordinateInPixels.StartPosition.x);
        int millisDistance = 0;

        int positionInSongInBeatsDragStart = noteAreaControl.ScreenPixelPositionToBeat(generalDragEvent.ScreenCoordinateInPixels.StartPosition.x);
        int beatDistance = 0;

        NoteAreaDragEvent result = new(generalDragEvent,
                                       midiNoteDragStart, midiNoteDistance,
                                       positionInSongInMillisDragStart, millisDistance,
                                       positionInSongInBeatsDragStart, beatDistance);

        return(result);
    }