Esempio n. 1
0
    public void OnDrag(PointerEventData eventData)                     //my drag function
    {
        Vector2 mousePosition   = CalculateMousePosition(eventData);   //calculating the mouse position
        Vector2 limitedPosition = this.LimitedPosition(mousePosition); //limit my mousePosition

        this.SetJoystickPosition(limitedPosition);                     //setting the stick/joystick position with this mouse position
        _OnValueChanged.Invoke(limitedPosition);                       //invoke my function placed on my unity event when i move my stick
    }
Esempio n. 2
0
    private void destroyTilesAndWalls(Vector2 positionScaled, Direction.Dir direction)
    {
        Vector2 usePositionScaled = positionScaled + Direction.convertDirToUnitVector2(direction);

        movedToTile.Invoke(grid.getTileLocation(usePositionScaled));
        if (((int)direction / 2) == 0)
        {
            usePositionScaled = positionScaled;
        }
        if (((int)direction % 2) == 0)
        {
            if (grid.hWallInBounds(usePositionScaled))
            {
                if (grid.getHWallState(usePositionScaled))
                {
                    movedThroughHWall.Invoke(usePositionScaled);
                }
            }
        }
        else
        {
            if (grid.vWallInBounds(usePositionScaled))
            {
                if (grid.getVWallState(usePositionScaled))
                {
                    movedThroughVWall.Invoke(usePositionScaled);
                }
            }
        }
    }
        void EditorInput()
        {
            var e = Event.current;


            switch (e.type)
            {
            case EventType.MouseDrag:
                if (e.button == 0)
                {
                    // トラックパッド対応
                    if (e.alt && e.command)
                    {
                        OnMouseDragMiddle.Invoke(e.delta);
                        e.Use();
                    }
                    else if (e.alt)
                    {
                        OnMouseDragRight.Invoke(e.delta);
                        e.Use();
                    }
                }
                else if (e.button == 1)
                {     // 右ドラッグ
                    OnMouseDragRight.Invoke(e.delta);
                    e.Use();
                }
                else if (e.button == 2)
                {     // ミドルドラッグ
                    OnMouseDragMiddle.Invoke(e.delta);
                    e.Use();
                }
                break;

            case EventType.ScrollWheel:
                OnScrollWheel.Invoke(e.delta.y);
                e.Use();
                break;
            }
        }
Esempio n. 4
0
        void Update()
        {
            var mousePos = Input.mousePosition;

            switch (positionType)
            {
            case PositionType.Screen:
                actions.Invoke(m_value = (Vector2)mousePos);
                break;

            case PositionType.World2D:
                actions.Invoke(m_value = (Vector2)Camera.main.ScreenToWorldPoint(mousePos));
                break;

            case PositionType.Viewport:
                actions.Invoke(m_value = (Vector2)Camera.main.ScreenToViewportPoint(mousePos));
                break;

            case PositionType.CenteredViewport:
                actions.Invoke(m_value = (Vector2)Camera.main.ScreenToViewportPoint(mousePos) * 2 - Vector2.one);
                break;
            }
        }
Esempio n. 5
0
        public void OnDrag(PointerEventData eventData)
        {
            if (!IsActive())
            {
                return;
            }

            if (!m_Dragging)
            {
                return;
            }

            if (eventData.button != PointerEventData.InputButton.Left)
            {
                return;
            }


            Vector2 canvasPoint = rectTransform.root.InverseTransformPoint(eventData.position);

            onDrag.Invoke(canvasPoint);
        }
 void IScrollHandler.OnScroll(PointerEventData eventData)
 {
     _scrolled.Invoke(Vector2.Scale(eventData.scrollDelta, _scale));
 }
Esempio n. 7
0
 void Update()
 {
     VectorAction.Invoke(new Vector2(Input.GetAxisRaw(HorizontalInput), Input.GetAxisRaw(VerticalInput)));
 }
Esempio n. 8
0
 void SetInput(Vector2 input)
 {
     OnHorizontalChanged.Invoke(input.x * multiplier.x);
     OnVerticalChanged.Invoke(input.y * multiplier.y);
     OnChanged.Invoke(input);
 }
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ public override void Invoke()
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ onInvoke.Invoke(value);
/*AUTO SCRIPT*/ }
 // Update is called once per frame
 void Update()
 {
     OutputTransformRight.Invoke(transform.right);
 }