Beispiel #1
0
 private void LateUpdate()
 {
     if (_lmbPressed == false && OnAreaChange != null)
     {
         OnAreaChangeArgs e            = new OnAreaChangeArgs();
         Vector2Int       cursorCoords = Utils.CursorToCoordinates();
         e.rectangle            = new fidt17.Utils.IntRectangle(cursorCoords, cursorCoords);
         e.startMousePosition   = cursorCoords;
         e.currentMousePosition = cursorCoords;
         e.dragEnded            = false;
         OnAreaChange.Invoke(e);
     }
 }
Beispiel #2
0
    private void ProcessSelectionArea(Vector2 start, Vector2 end)
    {
        DeselectEverything();
        GetSelectableInArea(start, end).ForEach(x => Select(x));
        ResetSelectionArea();
        OnSelect?.Invoke();

        if (OnAreaChange != null)
        {
            OnAreaChangeArgs e = new OnAreaChangeArgs();
            e.rectangle = new fidt17.Utils.IntRectangle(Utils.WorldToGrid(start), Utils.WorldToGrid(end));
            e.dragEnded = true;
            OnAreaChange.Invoke(e);
        }
    }
Beispiel #3
0
    private IEnumerator StartSelectionAreaDrag()
    {
        if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            yield break;
        }

        _lmbPressed = true;

        Vector2 startMousePosition   = Utils.CursorToWorldPosition();
        Vector2 currentMousePosition = startMousePosition;

        while (_lmbPressed)
        {
            currentMousePosition = Utils.CursorToWorldPosition();

            if (_settings.shouldDrawArea)
            {
                DrawSelectionArea(startMousePosition, currentMousePosition);
            }

            if (OnDrag != null)
            {
                List <SelectableComponent> selectableInArea = GetSelectableInArea(startMousePosition, currentMousePosition);
                OnDrag.Invoke(selectableInArea);
            }

            if (OnAreaChange != null)
            {
                OnAreaChangeArgs e = new OnAreaChangeArgs();
                e.rectangle            = new fidt17.Utils.IntRectangle(Utils.WorldToGrid(startMousePosition), Utils.WorldToGrid(currentMousePosition));
                e.startMousePosition   = startMousePosition;
                e.currentMousePosition = currentMousePosition;
                e.dragEnded            = false;
                OnAreaChange.Invoke(e);
            }
            yield return(null);
        }

        ProcessSelectionArea(startMousePosition, currentMousePosition);
    }