/// <summary>
        /// Occurs upon a valid <see cref="PanGesture"/> when the end (or beginning) of the sequence is reached and navigation to next/previous item may not be completed.
        /// </summary>
        /// <param name="panGesture"></param>
        protected override void OnPanStretch(PanGesture panGesture)
        {
            base.OnPanStretch(panGesture);

            double scaleFactor = 0.2;

            double offset = this.View.Orientation == Orientation.Horizontal ? panGesture.CumulativeTranslation.X : panGesture.CumulativeTranslation.Y;

            if (offset > 0)
            {
                offset = Math.Min(this.Panel.ItemLength * scaleFactor, offset);
            }
            else
            {
                offset = Math.Max(-this.Panel.ItemLength * scaleFactor, offset);
            }

            double absOffset = Math.Abs(offset);
            double scale     = 1 - (absOffset / (this.Panel.ItemLength + (absOffset / scaleFactor)));

            if (this.View.Orientation == Orientation.Horizontal)
            {
                this.transform.CenterX    = offset > 0 ? this.Panel.ItemLength : 0;
                this.transform.TranslateX = offset;
                this.transform.ScaleX     = scale;
            }
            else
            {
                this.transform.CenterY    = offset > 0 ? this.Panel.ItemLength : 0;
                this.transform.TranslateY = offset;
                this.transform.ScaleY     = scale;
            }
        }
Ejemplo n.º 2
0
        private void OnEnable()
        {
            rectTransform             = GetComponent <RectTransform>();
            rectTransform.pivot       = new Vector2(0.5f, 0.5f);
            PanGesture.ThresholdUnits = 0.0f;
            PanGesture.AllowSimultaneousExecutionWithAllGestures();
            PanGesture.StateUpdated += PanGestureUpdated;

#if UNITY_EDITOR
            if (JoystickImage != null && JoystickImage.canvas.renderMode != RenderMode.ScreenSpaceOverlay)
            {
                Debug.LogError("Fingers joystick script requires that if JoystickImage is set, the Canvas is in ScreenSpaceOverlay mode.");
            }
#endif

            if (!string.IsNullOrEmpty(CrossPlatformInputHorizontalAxisName) && !string.IsNullOrEmpty(CrossPlatformInputVerticalAxisName))
            {
                crossPlatformInputHorizontalAxisObject = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputHorizontalAxisName, out crossPlatformInputNewlyRegistered);
                crossPlatformInputVerticalAxisObject   = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputVerticalAxisName, out crossPlatformInputNewlyRegistered);
            }

            FingersScript.Instance.AddGesture(PanGesture);
            SetIdleState();
            homePosition = rectTransform.position;
        }
Ejemplo n.º 3
0
    protected override void onPanRunning(PanGesture gesture)
    {
        /*if (gesture.ActiveTouches.Count > 0)
         *      if (EventSystem.current.IsPointerOverGameObject ())
         *              return;*/

        if (gesture.ActiveTouches.Count > 0)
        {
            PointerEventData ped = new PointerEventData(EventSystem.current);
            ped.position = gesture.ScreenPosition;
            List <RaycastResult> hit = new List <RaycastResult>();
            EventSystem.current.RaycastAll(ped, hit);

            foreach (RaycastResult rr in hit)
            {
                if (rr.gameObject.name.Equals("MessageBox"))
                {
                    continue;
                }
                else
                {
                    return;
                }
            }
        }

        rotatedDirty = true;
        focusedObject.Rotate(0, -(gesture.ScreenPosition.x - gesture.PreviousScreenPosition.x) * .5f, 0, Space.World);
        GameObject.Find("MessageBox").GetComponent <Text>().text = focusedObject.eulerAngles.y.ToString("0") + "\u00B0";
    }
Ejemplo n.º 4
0
    protected override void onPanRunning(PanGesture gesture)
    {
        /*if (gesture.ActiveTouches.Count > 0)
         *      if (EventSystem.current.IsPointerOverGameObject ())
         *              return;*/

        if (gesture.ActiveTouches.Count > 0)
        {
            PointerEventData ped = new PointerEventData(EventSystem.current);
            ped.position = gesture.ScreenPosition;
            List <RaycastResult> hit = new List <RaycastResult>();
            EventSystem.current.RaycastAll(ped, hit);

            foreach (RaycastResult rr in hit)
            {
                if (rr.gameObject.name.Equals("MessageBox"))
                {
                    continue;
                }
                else
                {
                    return;
                }
            }
        }

        turnTableCamera.setDelta((gesture.ScreenPosition - gesture.PreviousScreenPosition) / 10.0f);
    }
Ejemplo n.º 5
0
    // Use this for initialization
    protected virtual void Start()
    {
        PressGesture press = gameObject.AddComponent <PressGesture> ();

        press.Pressed += TouchEvent;

        PanGesture pan = gameObject.AddComponent <PanGesture> ();

        pan.Panned += TouchEvent;

        TapGesture tap = gameObject.AddComponent <TapGesture>();

        tap.Tapped += TouchEvent;
        tap.NumberOfTapsRequired = 2;
        tap.TimeLimit            = 0.5f;

        ScaleGesture scale = gameObject.AddComponent <ScaleGesture> ();

        scale.Scaled += TouchEvent;

        gameObject.AddComponent <PressGesture>().Pressed += TouchEvent;

        LongPressGesture longPress = gameObject.AddComponent <LongPressGesture>();

        longPress.LongPressed += TouchEvent;
        longPress.TimeToPress  = 0.2f;
        longPress.AddFriendlyGesture(pan);

        gameObject.AddComponent <ReleaseGesture>().Released += TouchEvent;
    }
Ejemplo n.º 6
0
        public void ScrollableBaseOnAccessibilityPan()
        {
            tlog.Debug(tag, $"ScrollableBaseOnAccessibilityPan START");

            var testingTarget = new ScrollableBase()
            {
                Size               = new Size(100, 2),
                BackgroundColor    = Color.Cyan,
                ScrollingDirection = ScrollableBase.Direction.Vertical,
            };

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");

            using (PanGesture gesture = new PanGesture())
            {
                try
                {
                    testingTarget.OnAccessibilityPan(gesture);
                }
                catch (Exception e)
                {
                    tlog.Debug(tag, e.Message.ToString());
                    Assert.Fail("Caught Exception : Failed!");
                }
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"ScrollableBaseOnAccessibilityPan END (OK)");
        }
Ejemplo n.º 7
0
    public void HandlePanning(object sender, GameObject room)
    {
        PanGesture pg = (PanGesture)sender;

        if (aWallIsSelected)
        {
            Ray   ray    = Camera.main.ScreenPointToRay(new Vector3(pg.ScreenPosition.x, pg.ScreenPosition.y, 0));
            float t      = (hitY - ray.origin.y) / ray.direction.y;
            float factor = 1.0F;
            if (selectedWall == 1)
            {
                float z = ray.origin.z + ray.direction.z * t;
                z = (int)(Math.Round(z / 0.025F)) * 0.025F;
                float oldZ = room.gameObject.transform.Find(toS[0]).transform.position.z;
                room.gameObject.transform.Find(toS[0]).transform.Translate(new Vector3(0, 0, factor * (z - oldZ)));
                room.gameObject.transform.Find(toS[2]).transform.Translate(new Vector3(0, 0, factor * (z - oldZ)));
            }
            else if (selectedWall == 4)
            {
                float x = ray.origin.x + ray.direction.x * t;
                x = (int)(Math.Round(x / 0.025F)) * 0.025F;
                float oldX = room.gameObject.transform.Find(toS[3]).transform.position.x;
                room.gameObject.transform.Find(toS[1]).transform.Translate(new Vector3(0, 0, factor * (oldX - x)));
                room.gameObject.transform.Find(toS[3]).transform.Translate(new Vector3(0, 0, factor * (oldX - x)));
            }
        }
    }
        IEnumerator _Initialize(AssociationPiece piece)
        {
            var rb = GetComponent <Rigidbody>();

            rb.useGravity = false;
            rb.WakeUp();
            rb.isKinematic = true;
            yield return(null);

            var tranf = GetComponent <Transformer2D>();

            tranf.Speed = 25;

            _pg = GetComponent <PanGesture>();

            if (!string.IsNullOrEmpty(piece.sprite))
            {
                var image = GetComponent <Image>();
                if (!image)
                {
                    image = gameObject.AddComponent <Image>();
                }

                image.sprite = Resources.Load <Sprite>(piece.sprite);
            }

            Id = piece.id;

            IsStatic = piece.isStatic;

            _controllerType = ControllerTypes.Association;


            Initialize();
        }
Ejemplo n.º 9
0
        internal static PanGesture GetPanGestureFromPtr(global::System.IntPtr cPtr)
        {
            PanGesture ret = new PanGesture(cPtr, false);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 10
0
        public void PanGestureGetPanGestureFromPtr()
        {
            tlog.Debug(tag, $"PanGestureGetPanGestureFromPtr START");
            PanGesture a1 = new PanGesture();
            PanGesture a2 = PanGesture.GetPanGestureFromPtr(PanGesture.getCPtr(a1).Handle);

            a1.Dispose();
            tlog.Debug(tag, $"PanGestureGetPanGestureFromPtr END (OK)");
            Assert.Pass("PanGestureGetPanGestureFromPtr");
        }
        protected override void OnStart()
        {
            base.OnStart();

            _pg = GetComponent <PanGesture>();

            var input = _controller as InputController;

            input.AddPanGesture(_pg);
        }
Ejemplo n.º 12
0
        public void PanGestureDetectorSetPanGestureProperties()
        {
            tlog.Debug(tag, $"PanGestureDetectorSetPanGestureProperties START");
            PanGesture pan = new PanGesture();

            PanGestureDetector.SetPanGestureProperties(pan);

            tlog.Debug(tag, $"PanGestureDetectorSetPanGestureProperties END (OK)");
            Assert.Pass("PanGestureDetectorClearAngles");
        }
Ejemplo n.º 13
0
        private void OnDetected(object obj, PanGestureDetector.DetectedEventArgs e)
        {
            View v1 = e.View;

            e.View = v1;

            PanGesture p1 = e.PanGesture;

            e.PanGesture = p1;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Occurs upon a valid <see cref="PanGesture"/>.
        /// </summary>
        /// <param name="gesture"></param>
        protected override void OnPan(PanGesture gesture)
        {
            base.OnPan(gesture);

            this.PreparePan(this.OffsetLength);
            if (this.snapshotState == SnapshotState.Ready)
            {
                this.UpdateProjections();
            }
        }
Ejemplo n.º 15
0
        public void PanGestureNumberOfTouches()
        {
            tlog.Debug(tag, $"PanGestureNumberOfTouches START");
            PanGesture a1 = new PanGesture();
            uint       b1 = a1.NumberOfTouches;

            a1.Dispose();

            tlog.Debug(tag, $"PanGestureNumberOfTouches END (OK)");
            Assert.Pass("PanGestureNumberOfTouches");
        }
Ejemplo n.º 16
0
        public void PanGesturePosition()
        {
            tlog.Debug(tag, $"PanGesturePosition START");
            PanGesture a1 = new PanGesture();
            Vector2    v1 = a1.Position;

            a1.Dispose();

            tlog.Debug(tag, $"PanGesturePosition END (OK)");
            Assert.Pass("PanGesturePosition");
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Occurs upon a valid <see cref="PanGesture"/> when the end (or beginning) of the sequence is reached and navigation to next/previous item may not be completed.
        /// </summary>
        /// <param name="panGesture"></param>
        protected override void OnPanStretch(PanGesture panGesture)
        {
            base.OnPanStretch(panGesture);

            double length = this.View.Orientation == Orientation.Horizontal ? panGesture.CumulativeTranslation.X : panGesture.CumulativeTranslation.Y;

            this.PreparePan(length);
            this.rotation = Math.Min(this.rotation, 60);

            this.UpdateProjections();
        }
Ejemplo n.º 18
0
        public void PanGestureVelocity()
        {
            tlog.Debug(tag, $"PanGestureVelocity START");
            PanGesture a1 = new PanGesture();
            Vector2    v1 = a1.Velocity;

            a1.Dispose();

            tlog.Debug(tag, $"PanGestureVelocity END (OK)");
            Assert.Pass("PanGestureVelocity");
        }
Ejemplo n.º 19
0
        public void PanGestureGetScreenDistance()
        {
            tlog.Debug(tag, $"PanGestureGetScreenDistance START");
            PanGesture a1 = new PanGesture();
            float      f1 = a1.GetScreenDistance();

            a1.Dispose();

            tlog.Debug(tag, $"PanGestureGetScreenDistance END (OK)");
            Assert.Pass("PanGestureGetScreenDistance");
        }
Ejemplo n.º 20
0
        public void PanGestureGetSpeed()
        {
            tlog.Debug(tag, $"PanGestureGetSpeed START");
            PanGesture a1 = new PanGesture();
            float      f1 = a1.GetSpeed();

            a1.Dispose();

            tlog.Debug(tag, $"PanGestureGetSpeed END (OK)");
            Assert.Pass("PanGestureGetSpeed");
        }
Ejemplo n.º 21
0
        public void PanGestureDisplacement()
        {
            tlog.Debug(tag, $"PanGestureDisplacement START");
            PanGesture a1 = new PanGesture();
            Vector2    v1 = a1.Displacement;

            a1.Dispose();

            tlog.Debug(tag, $"PanGestureDisplacement END (OK)");
            Assert.Pass("PanGestureDisplacement");
        }
Ejemplo n.º 22
0
        protected override void OnStart()
        {
            base.OnStart();

            _panGesture  = GetComponent <PanGesture>();
            _boxCollider = GetComponent <BoxCollider>();

            inputController = _controller as InputController;

            inputController.AddPanGesture(_panGesture);
        }
 /// <summary>
 /// Occurs upon a valid <see cref="PanGesture"/>.
 /// </summary>
 /// <param name="gesture"></param>
 protected override void OnPan(PanGesture gesture)
 {
     if (this.View.Orientation == Orientation.Horizontal)
     {
         this.transform.TranslateX = this.Offset.X;
     }
     else
     {
         this.transform.TranslateY = this.Offset.Y;
     }
 }
Ejemplo n.º 24
0
        public void PanGesturegetCPtr()
        {
            tlog.Debug(tag, $"PanGesturegetCPtr START");
            PanGesture a1 = new PanGesture();

            global::System.Runtime.InteropServices.HandleRef ptr = PanGesture.getCPtr(a1);

            a1.Dispose();

            tlog.Debug(tag, $"PanGesturegetCPtr END (OK)");
            Assert.Pass("PanGestureCPtr");
        }
Ejemplo n.º 25
0
        private void OnDetected(object obj, PanGestureDetector.DetectedEventArgs e)
        {
            View view = e.View;

            e.View = view;

            PanGesture gesture = e.PanGesture;

            e.PanGesture = gesture;

            tlog.Debug(tag, "Handled : " + e.Handled);
        }
Ejemplo n.º 26
0
        public void PanGestureConstructorWithState()
        {
            tlog.Debug(tag, $"PanGestureConstructorWithState START");

            var testingTarget = new PanGesture(Gesture.StateType.Finished);

            Assert.IsNotNull(testingTarget, "Can't create success object Hover");
            Assert.IsInstanceOf <PanGesture>(testingTarget, "Should be an instance of PanGesture type.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"PanGestureConstructorWithState END (OK)");
            Assert.Pass("PanGestureConstructor");
        }
Ejemplo n.º 27
0
        public void PanGestureConstructor()
        {
            tlog.Debug(tag, $"PanGestureConstructor START");
            PanGesture a1 = new PanGesture();

            Gesture.StateType state = Gesture.StateType.Finished;
            PanGesture        a2    = new PanGesture(state);

            a2.Dispose();
            a1.Dispose();
            tlog.Debug(tag, $"PanGestureConstructor END (OK)");
            Assert.Pass("PanGestureConstructor");
        }
Ejemplo n.º 28
0
        protected override void OnStart()
        {
            base.OnStart();

            _inputController = _controller as InputController;
            _inputController.AddFloatController();

            _pg               = GetComponent <PanGesture>();
            _pg.Panned       += Pan;
            _pg.PanCompleted += EndPan;
            _iniPos           = transform.position;

            bx      = GetComponent <BoxCollider>();
            bx.size = new Vector3(GetComponent <RectTransform>().rect.width, GetComponent <RectTransform>().rect.height, 1);
        }
Ejemplo n.º 29
0
        // Handle pan start events
        private void panStartedHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us which object was pressed
            PanGesture gesture = sender as PanGesture;

            // get info about where the hit object was located when the gesture was recognized
            ITouchHit hit;

            if (gesture.GetTargetHitResult(out hit))
            {
                // want the info as a 2D point
                ITouchHit2D hit2d = (ITouchHit2D)hit;
                Debug.Log("PAN STARTED on " + gesture.gameObject.name + " at " + hit2d.Point);
            }
        }
Ejemplo n.º 30
0
        public void PanGestureGetScreenSpeed()
        {
            tlog.Debug(tag, $"PanGestureGetScreenSpeed START");

            var testingTarget = new PanGesture(Gesture.StateType.Finished);

            Assert.IsNotNull(testingTarget, "Can't create success object Hover");
            Assert.IsInstanceOf <PanGesture>(testingTarget, "Should be an instance of PanGesture type.");

            tlog.Debug(tag, "GetScreenSpeed : " + testingTarget.GetScreenSpeed());

            testingTarget.Dispose();
            tlog.Debug(tag, $"PanGestureGetScreenSpeed END (OK)");
            Assert.Pass("PanGestureGetScreenSpeed");
        }