コード例 #1
0
 private void HandleFadeOut()
 {
     _submitHandler = null;
     _buttonHandler = null;
     _stickHandler  = null;
     EventSystem.current.SetSelectedGameObject(null);
 }
コード例 #2
0
 private void HandleDialog()
 {
     ScrollRect[] scrollRects;
     _scrollRects     = new Dictionary <int, ScrollRect>();
     _selectedIndices = new Dictionary <int, int>();
     if (dialogManager.NumDialogs > 0)
     {
         DialogView dialog = dialogManager.GetTopDialog().GetComponent <DialogView>();
         _submitHandler    = dialog as ISubmitHandler;
         _buttonHandler    = dialog as IButtonInputHandler;
         _stickHandler     = dialog as IAnalogInputHandler;
         _directionHandler = dialog as IDirectionInputHandler;
         scrollRects       = (dialog as IScrollInputHandler)?.GetScrollRects();
     }
     else
     {
         SceneView scene = sceneMediator.SceneObject.GetComponent <SceneView>();
         _submitHandler    = scene as ISubmitHandler;
         _buttonHandler    = scene as IButtonInputHandler;
         _stickHandler     = scene as IAnalogInputHandler;
         _directionHandler = scene as IDirectionInputHandler;
         scrollRects       = (scene as IScrollInputHandler)?.GetScrollRects();
     }
     if (scrollRects != null)
     {
         for (int i = scrollRects.Length - 1; i >= 0; --i)
         {
             if (scrollRects[i] != null)
             {
                 _scrollRects[i]     = scrollRects[i];
                 _selectedIndices[i] = 0;
             }
         }
     }
 }
コード例 #3
0
        public SubmitController(ISubmitHandler submitHandler)
            : base("v1/diff")
        {
            _submitHandler = submitHandler;

            Post("{id:guid}/left", async(args, ct) => await PostIt(args.id, SubmitKey.Left));
            Post("{id:guid}/right", async(args, ct) => await PostIt(args.id, SubmitKey.Right));
        }
コード例 #4
0
ファイル: UITest.cs プロジェクト: wuxijin999/Wizard_Script
    private void SeekChildComponent(Transform _transform)
    {
        if (_transform == null)
        {
            return;
        }
        Component            component = null;
        IPointerClickHandler click     = null;
        IPointerDownHandler  down      = null;
        IPointerUpHandler    up        = null;
        ISubmitHandler       submit    = null;
        Transform            transform = null;

        for (int i = 0; i < _transform.childCount; i++)
        {
            transform = _transform.GetChild(i);
            click     = transform.GetComponent <IPointerClickHandler>();
            down      = transform.GetComponent <IPointerDownHandler>();
            up        = transform.GetComponent <IPointerUpHandler>();
            submit    = transform.GetComponent <ISubmitHandler>();

            if (click != null)
            {
                component = click as Component;
                hashClick[click.GetHashCode()]      = click;
                clickTestTimes[click.GetHashCode()] = 0;
                hashComponent[click.GetHashCode()]  = component;
            }

            if (down != null)
            {
                component = down as Component;
                hashDown[down.GetHashCode()]      = down;
                downTestTimes[down.GetHashCode()] = 0;
                hashComponent[down.GetHashCode()] = component;
            }

            if (up != null)
            {
                component = up as Component;
                hashUp[up.GetHashCode()]        = up;
                upTestTimes[up.GetHashCode()]   = 0;
                hashComponent[up.GetHashCode()] = component;
            }

            if (submit != null)
            {
                component = submit as Component;
                hashSubmit[submit.GetHashCode()]      = submit;
                submitTestTimes[submit.GetHashCode()] = 0;
                hashComponent[submit.GetHashCode()]   = component;
            }

            SeekChildComponent(_transform.GetChild(i));
        }
    }
    public static int OnSubmit(IntPtr l)
    {
        int result;

        try
        {
            ISubmitHandler submitHandler = (ISubmitHandler)LuaObject.checkSelf(l);
            BaseEventData  eventData;
            LuaObject.checkType <BaseEventData>(l, 2, out eventData);
            submitHandler.OnSubmit(eventData);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
コード例 #6
0
ファイル: ExecuteEvents.cs プロジェクト: jiahaodev/UGUI
 private static void Execute(ISubmitHandler handler, BaseEventData eventData)
 {
     handler.OnSubmit(eventData);
 }
コード例 #7
0
 private void Awake()
 {
     m_selectable = GetComponent <Selectable>();
     m_submit     = GetComponent <ISubmitHandler>();
 }
コード例 #8
0
    public void OnGUI()
    {
        if (testTool == null)
        {
            return;
        }
        GUILayout.Space(40);
        if (testTool.auto)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(400);
            EditorGUILayout.LabelField(string.Format("累计时间  {0} 秒", (int)testTool.autoCumulativeTime), GUILayout.ExpandWidth(true));
            GUILayout.Space(400);
            GUILayout.EndHorizontal();
        }
        GUILayout.Space(20);
        GUILayout.BeginHorizontal();
        GUILayout.Space(50);
        testTool.interVal = EditorGUILayout.FloatField("测试间隔", testTool.interVal, GUILayout.ExpandWidth(true));
        GUILayout.Space(50);
        testTool.TouchCount = EditorGUILayout.IntField("多点模拟", testTool.TouchCount, GUILayout.ExpandWidth(true));
        GUILayout.Space(50);
        if (!testTool.auto)
        {
            if (GUILayout.Button("开始", GUILayout.Width(50)))
            {
                testTool.StartAutoTest();
            }
        }
        else
        {
            if (GUILayout.Button("结束", GUILayout.Width(50)))
            {
                testTool.StopAutoTest();
            }
        }
        GUILayout.Space(50);
        GUILayout.EndHorizontal();
        GUILayout.Space(40);

        foreach (int key in testTool.hashComponent.Keys)
        {
            Component component = testTool.hashComponent[key];
            if (component == null)
            {
                continue;
            }
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();

            GUILayout.Space(50);

            GUILayout.Label(component.gameObject.name, GUILayout.Width(150));
            IPointerClickHandler click  = null;
            IPointerDownHandler  down   = null;
            IPointerUpHandler    up     = null;
            ISubmitHandler       submit = null;

            GUILayout.Space(10);
            if (testTool.hashClick.TryGetValue(key, out click))
            {
                if (GUILayout.Button("Click"))
                {
                    click.OnPointerClick(new PointerEventData(EventSystem.current));
                    testTool.clickTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.clickTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.Space(10);
            if (testTool.hashDown.TryGetValue(key, out down))
            {
                if (GUILayout.Button("Down"))
                {
                    down.OnPointerDown(new PointerEventData(EventSystem.current));
                    testTool.downTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.downTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.Space(10);
            if (testTool.hashUp.TryGetValue(key, out up))
            {
                if (GUILayout.Button("Up"))
                {
                    up.OnPointerUp(new PointerEventData(EventSystem.current));
                    testTool.upTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.upTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.Space(10);
            if (testTool.hashSubmit.TryGetValue(key, out submit))
            {
                if (GUILayout.Button("Submit"))
                {
                    submit.OnSubmit(new PointerEventData(EventSystem.current));
                    testTool.submitTestTimes[key]++;
                }

                EditorGUILayout.LabelField(testTool.submitTestTimes[key].ToString(), GUILayout.Width(30));
            }

            GUILayout.EndHorizontal();
        }

        Repaint();
    }
コード例 #9
0
ファイル: VRTargetItem.cs プロジェクト: tecedufurb/pluvia
 private void Awake()
 {
     m_trigger = GetComponent <EventTrigger>();
     m_submit  = GetComponent <ISubmitHandler>();
 }
コード例 #10
0
        void Update()
        {
            Cursor.SetCursor(Input.GetMouseButton(0) ? CursorClick : CursorRest, HotSpot, CursorMode);
#if DEBUG
            if (Input.GetKeyDown(KeyCode.F10))
            {
                AmbitionApp.SendMessage(GameMessages.TOGGLE_CONSOLE);
            }
#endif
            Vector2 direction = Vector2.zero;

            // Button Down
            if (Input.GetButtonDown(SUBMIT_BTN))
            {
                _submitHandler?.Submit();
            }
            else if (Input.GetButtonDown(CANCEL_BTN))
            {
                _submitHandler?.Cancel();
            }

            else if (Input.GetButtonDown(X_BTN))
            {
                _buttonHandler?.HandleInput(X_BTN, false);
            }
            else if (Input.GetButtonDown(Y_BTN))
            {
                _buttonHandler?.HandleInput(Y_BTN, false);
            }


            // Holding Button
            if (Input.GetButton(X_BTN))
            {
                _buttonHandler?.HandleInput(X_BTN, true);
            }
            else if (Input.GetButton(Y_BTN))
            {
                _buttonHandler?.HandleInput(Y_BTN, true);
            }

#if UNITY_STANDALONE
            if (_stickHandler != null)
            {
                direction = Vector2.zero;
                if (Input.GetKey(KeyCode.A))
                {
                    direction.x = -1;
                }
                else if (Input.GetKey(KeyCode.D))
                {
                    direction.x = 1;
                }
                if (Input.GetKey(KeyCode.W))
                {
                    direction.y = 1;
                }
                else if (Input.GetKey(KeyCode.S))
                {
                    direction.y = -1;
                }
                _sticks[0] = direction;

                if (Input.GetKey(KeyCode.Keypad1))
                {
                    direction.x = direction.y = -1;
                }
                else if (Input.GetKey(KeyCode.Keypad2))
                {
                    direction.y = -1;
                }
                else if (Input.GetKey(KeyCode.Keypad4))
                {
                    direction.x = -1;
                }
                else if (Input.GetKey(KeyCode.Keypad6))
                {
                    direction.x = 1;
                }
                else if (Input.GetKey(KeyCode.Keypad8))
                {
                    direction.y = 1;
                }
                else if (Input.GetKey(KeyCode.Keypad9))
                {
                    direction.x = direction.y = 1;
                }
                else if (Input.GetKey(KeyCode.Keypad3))
                {
                    direction.x = 1;
                    direction.y = -1;
                }
                else if (Input.GetKey(KeyCode.Keypad7))
                {
                    direction.x = -1;
                    direction.y = 1;
                }
                else
                {
                    direction = Vector2.zero;
                }
                _sticks[1] = direction;
                _stickHandler.HandleInput(_sticks);
            }

            if (_directionHandler != null)
            {
                direction = Vector2.zero;
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    direction.x = 1;
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    direction.x = 1;
                }
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    direction.y = 1;
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    direction.y = -1;
                }
                _directionHandler?.HandleInput((int)direction.x, (int)direction.y);
            }

            float val = Input.GetAxis("direction_1_x");
            if (val != 0)
            {
                Debug.Log(val);
            }
#else
            else if (_submitHandler != null)
            {
                if (Input.GetButtonDown("Submit"))
                {
                    _submitHandler.Submit();
                    _submitHandler = null;
                }
                else if (Input.GetButtonDown("Cancel"))
                {
                    _submitHandler.Cancel();
                    _submitHandler = null;
                }
            }

            if (_buttonHandler != null)
            {
                for (int i = 1; i <= 4; ++i)
                {
                    if (Input.GetButtonDown("button_" + i))
                    {
                        _buttonHandler.HandleInput(i);
                    }
                }
            }

            if (_stickHandler != null)
            {
                // 0 = left analog
                // 1 = right analog
                // 2 = directional pad
                // 3 = bumpers/triggers
                Vector2 direction;
                for (int i = 0; i <= 2; ++i)
                {
                    direction.x = Input.GetAxis("direction_" + i + "_x");
                    direction.y = Input.GetAxis("direction_" + i + "_x");
                    if (direction.sqrMagnitude > 0)
                    {
                        _stickHandler.HandleInput(i, direction);
                    }
                }
                direction = Vector2.zero;
                if (Input.GetButtonDown("right"))
                {
                    direction.x = 1f;
                }
                if (Input.GetButtonDown("left"))
                {
                    direction.x -= 1f;
                }
                if (Input.GetButtonDown("up"))
                {
                    direction.y = 1f;
                }
                if (Input.GetButtonDown("down"))
                {
                    direction.y -= 1f;
                }
                if (direction.sqrMagnitude > 0)
                {
                    _stickHandler.HandleInput(3, direction);
                }

                direction = Vector2.zero;
                if (Input.GetButtonDown("bumper_r"))
                {
                    direction.x = 1f;
                }
                if (Input.GetButtonDown("bumper_l"))
                {
                    direction.x -= 1f;
                }
                if (direction.x != 0)
                {
                    _stickHandler.HandleInput(4, direction);
                }
            }
#endif
        }