Пример #1
0
        public static FunctionUpdater CreateMouseClickFromToAction(int mouseButton, int cancelMouseButton, Action <Vector3, Vector3> onMouseClickFromTo, Action <Vector3, Vector3> onWaitingForToPosition)
        {
            int     state = 0;
            Vector3 from  = Vector3.zero;

            return(FunctionUpdater.Create(() => {
                if (state == 1)
                {
                    if (onWaitingForToPosition != null)
                    {
                        onWaitingForToPosition(from, UtilsClass.GetMouseWorldPosition());
                    }
                }
                if (state == 1 && Input.GetMouseButtonDown(cancelMouseButton))
                {
                    // Cancel
                    state = 0;
                }
                if (Input.GetMouseButtonDown(mouseButton) && !UtilsClass.IsPointerOverUI())
                {
                    if (state == 0)
                    {
                        state = 1;
                        from = UtilsClass.GetMouseWorldPosition();
                    }
                    else
                    {
                        state = 0;
                        onMouseClickFromTo(from, UtilsClass.GetMouseWorldPosition());
                    }
                }
                return false;
            }));
        }
Пример #2
0
        public static FunctionUpdater CreateMouseDraggingAction(int mouseButton, Action <Vector3> onMouseDragging)
        {
            bool dragging = false;

            return(FunctionUpdater.Create(() => {
                if (Input.GetMouseButtonDown(mouseButton))
                {
                    dragging = true;
                }
                if (Input.GetMouseButtonUp(mouseButton))
                {
                    dragging = false;
                }
                if (dragging)
                {
                    onMouseDragging(UtilsClass.GetMouseWorldPosition());
                }
                return false;
            }));
        }