Exemple #1
0
        // ------------------------------------------------------------------------------------------------------------------------------------------

        void processUiEvent(Event ui)
        {
            if (ui.plane == null || ui.plane.interFace == null)
            {
                return;
            }

            ui.callback = "";

            UIArgs args = new UIArgs();

            args.delta   = Vector3.zero;
            args.uiEvent = ui;

            InterFace interFace = ui.plane.interFace;

            switch (ui.action)
            {
            case ACTION.TAP:

                if (ui.targetJustTapped)
                {
                    Verbose("Double tap.");

                    if (ui.target2D != null)
                    {
                        interFace.doubletap_2d(this, args);
                    }
                    else if (ui.target3D != null)
                    {
                        interFace.doubletap_3d(this, args);
                    }
                    else
                    {
                        interFace.doubletap_none(this, args);
                    }

                    ui.action = ACTION.SINGLEDRAG;
                }
                else
                {
                    if (ui.tapTimeOut < float.Epsilon)
                    {
                        //       Log("Setting tap time out");
                        ui.tapTimeOut = Time.time + 0.1f;
                    }
                    else if (Time.time > ui.tapTimeOut)
                    {
                        Verbose("tap timed out, single tap.");
                        ui.tapTimeOut = 0;

                        if (ui.target2D != null)
                        {
                            interFace.tap_2d(this, args);
                        }
                        else if (ui.target3D != null)
                        {
                            interFace.tap_3d(this, args);
                        }
                        else
                        {
                            interFace.tap_none(this, args);
                        }

                        ui.action = ACTION.SINGLEDRAG;
                    }
                }


                // also perform single drag (which'll allow things like springs to work while waiting for timeout)

                args.delta = new Vector3(ui.scaledDx, ui.scaledDy, 0);

                if (ui.target2D != null)
                {
                    interFace.single_2d(this, args);
                }
                else if (ui.target3D != null)
                {
                    interFace.single_3d(this, args);
                }
                else
                {
                    interFace.single_none(this, args);
                }


                break;

            case ACTION.SINGLEDRAG:

                // If this is an orthodrag button, we need to set and lock the initial direction.
                // We also get the appropriate targets and constraints for that direction and load them into the uievent.

                if (ui.targetButton != null && ui.targetButton.orthoDragging && ui.direction == DIRECTION.FREE)
                {
                    if (Mathf.Abs(ui.scaledDx) > Mathf.Abs(ui.scaledDy))
                    {
                        ui.direction = DIRECTION.HORIZONTAL;
                        Verbose("Locking to drag horizontally");
                    }
                    if (Mathf.Abs(ui.scaledDx) < Mathf.Abs(ui.scaledDy))
                    {
                        ui.direction = DIRECTION.VERTICAL;
                        Verbose("Locking to drag vertically");
                    }
                }
                //Verbose("singledrag");
                args.delta = new Vector3(ui.scaledDx, ui.scaledDy, 0);

                if (ui.target2D != null)
                {
                    interFace.single_2d(this, args);
                }
                else if (ui.target3D != null)
                {
                    interFace.single_3d(this, args);
                }
                else
                {
                    interFace.single_none(this, args);
                }

                // interFace.AddMapping

                //      ui.isInert = false;
                //    ui.isSpringing = false;

                break;

            case ACTION.DOUBLEDRAG:

                args.delta = new Vector3(ui.scaledDx, ui.scaledDy, ui.scaledDd);

                if (ui.target2D != null)
                {
                    interFace.double_2d(this, args);
                }
                else if (ui.target3D != null)
                {
                    interFace.double_3d(this, args);
                }
                else
                {
                    interFace.double_none(this, args);
                }

                break;

            default:

                interFace.none(this, args);

                break;
            }


            ui.Inertia();
        }
Exemple #2
0
        // ------------------------------------------------------------------------------------------------------------------------------------------

        void processUiEvent(Event ui)
        {
            if (ui.plane == null || ui.plane.interFace == null)
            {
                return;
            }

            ui.callback = "";

            UIArgs args = new UIArgs();

            args.delta   = Vector3.zero;
            args.uiEvent = ui;

            InterFace interFace = ui.plane.interFace;

            switch (ui.action)
            {
            case ACTION.TAP:

                ui.action = ACTION.SINGLEDRAG;

                if (ui.target2D != null)
                {
                    interFace.tap_2d(this, args);
                }
                else if (ui.target3D != null)
                {
                    interFace.tap_3d(this, args);
                }
                else
                {
                    interFace.tap_none(this, args);
                }

                break;

            case ACTION.SINGLEDRAG:

                // If this is an orthodrag button, we need to set and lock the initial direction.
                // We also get the appropriate targets and constraints for that direction and load them into the uievent.

                if (ui.targetButton != null && ui.targetButton.orthoDragging && ui.direction == DIRECTION.FREE)
                {
                    if (Mathf.Abs(ui.scaledDx) > Mathf.Abs(ui.scaledDy))
                    {
                        ui.direction = DIRECTION.HORIZONTAL;
                        Verbose("Locking to drag horizontally");
                    }
                    if (Mathf.Abs(ui.scaledDx) < Mathf.Abs(ui.scaledDy))
                    {
                        ui.direction = DIRECTION.VERTICAL;
                        Verbose("Locking to drag vertically");
                    }
                }
                //      Verbose("singledrag");
                args.delta = new Vector3(ui.scaledDx, ui.scaledDy, 0);

                if (ui.target2D != null)
                {
                    interFace.single_2d(this, args);
                }
                else if (ui.target3D != null)
                {
                    interFace.single_3d(this, args);
                }
                else
                {
                    interFace.single_none(this, args);
                }

                // interFace.AddMapping

                //      ui.isInert = false;
                //    ui.isSpringing = false;

                break;

            case ACTION.DOUBLEDRAG:

                args.delta = new Vector3(ui.scaledDx, ui.scaledDy, ui.scaledDd);

                if (ui.target2D != null)
                {
                    interFace.double_2d(this, args);
                }
                else if (ui.target3D != null)
                {
                    interFace.double_3d(this, args);
                }
                else
                {
                    interFace.double_none(this, args);
                }

                break;

            default:

                interFace.none(this, args);

                break;
            }


            ui.Inertia();
        }