/// <summary>This will spawn Prefab at the specified finger based on the ScreenDepth setting.</summary>
        public void Spawn(LeanFinger finger)
        {
            if (Prefab != null && finger != null)
            {
                // Spawn and position
                var clone = Instantiate(Prefab);

                UpdateSpawnedTransform(finger, clone);

                clone.gameObject.SetActive(true);

                if (DragAfterSpawn == true)
                {
                    var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

                    fingerData.Clone = clone;
                }

                // Select?
                var selectable = clone.GetComponent <LeanSelectable>();

                if (selectable != null)
                {
                    selectable.Select(finger);
                }
            }
        }
        private void HandleFingerDown(LeanFinger finger)
        {
            // Limit to one selection box
            if (fingerDatas.Count > 0)
            {
                return;
            }

            // Only use fingers clear of the GUI
            if (IgnoreIfStartedOverGui == true && finger.StartedOverGui == true)
            {
                return;
            }

            // Make new link
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            // Assign this finger to this link
            fingerData.Finger = finger;

            // Create LineRenderer instance for this link
            fingerData.Box = Instantiate(Prefab);

            fingerData.Box.gameObject.SetActive(true);

            // Move box to root
            fingerData.Box.transform.SetParent(Root, false);
        }
Esempio n. 3
0
        private void FingerSet(LeanFinger finger)
        {
            // ignore?
            if (MaxLines > 0 && fingerDatas.Count >= MaxLines)
            {
                return;
            }

            if (IgnoreStartedOverGui == true && finger.StartedOverGui == true)
            {
                return;
            }

            if (IgnoreIsOverGui == true && finger.IsOverGui == true)
            {
                return;
            }

            if (RequiredSelectable != null && RequiredSelectable.IsSelectedBy(finger) == false)
            {
                return;
            }

            // Get data for this finger
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            // Create line?
            if (fingerData.Line == null)
            {
                fingerData.Line = Instantiate(LinePrefab);
            }

            // Write line data
            WritePositions(fingerData.Line, fingerData.Finger);
        }
Esempio n. 4
0
        private void HandleFingerDown(LeanFinger finger)
        {
            if (Select != null)
            {
                if (RequireNoSelectables == true && LeanSelectable.IsSelectedCount > 0)
                {
                    return;
                }

                if (DeselectAllAtStart == true)
                {
                    LeanSelectable.DeselectAll();
                }

                if (RequireInitialSelection == true)
                {
                    waitingForSelection = true;

                    Select.SelectScreenPosition(finger);

                    waitingForSelection = false;
                }
                else
                {
                    LeanFingerData.FindOrCreate(ref fingerDatas, finger);

                    Select.SelectScreenPosition(finger);
                }
            }
        }
Esempio n. 5
0
        private void FingerDown(LeanFinger finger)
        {
            // Ignore?
            if (MaxLines > 0 && fingerDatas.Count >= MaxLines)
            {
                return;
            }

            if (IgnoreStartedOverGui == true && finger.StartedOverGui == true)
            {
                return;
            }

            if (IgnoreIsOverGui == true && finger.IsOverGui == true)
            {
                return;
            }

            // Make new link
            var leanFingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            // Create LineRenderer instance for this link
            leanFingerData.Line = Instantiate(LinePrefab);

            // Add new link to list
            fingerDatas.Add(leanFingerData);
        }
Esempio n. 6
0
        /// <summary>If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.</summary>
        public void AddFinger(LeanFinger finger)
        {
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            fingerData.Points.Clear();

            fingerData.Points.Add(finger.ScreenPosition);
        }
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = Use.GetFingers(true);

            for (var i = 0; i < fingers.Count; i++)
            {
                var finger = fingers[i];

                if (LeanFingerData.Exists(fingerDatas, finger) == false)
                {
                    // Too many active links?
                    if (MaxTrails >= 0 && LeanFingerData.Count(fingerDatas) >= MaxTrails)
                    {
                        continue;
                    }

                    if (Prefab != null)
                    {
                        // Spawn and activate
                        var clone = Instantiate(Prefab);

                        clone.gameObject.SetActive(true);

                        // Register with FingerData
                        var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

                        fingerData.Line  = clone;
                        fingerData.Age   = 0.0f;
                        fingerData.Width = Prefab.widthMultiplier;
                    }
                }
            }

            // Update all FingerData
            for (var i = fingerDatas.Count - 1; i >= 0; i--)
            {
                var fingerData = fingerDatas[i];

                if (fingerData.Line != null)
                {
                    UpdateLine(fingerData, fingerData.Finger, fingerData.Line);

                    if (fingerData.Age >= FadeTime)
                    {
                        Destroy(fingerData.Line.gameObject);

                        fingerDatas.RemoveAt(i);
                    }
                }
                else
                {
                    fingerDatas.RemoveAt(i);
                }
            }
        }
Esempio n. 8
0
		private void HandleFingerDown(LeanFinger finger)
		{
			if (IgnoreStartedOverGui == true && finger.StartedOverGui == true)
			{
				return;
			}

			// Get link for this finger and reset
			var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

			fingerData.Movement = Vector2.zero;

			fingers.Add(finger);
		}
Esempio n. 9
0
        private void AddFinger(LeanFinger finger, int index, bool reverse)
        {
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, null);             // We want to be able to store multiple links per finger, so pass null initially

            fingerData.Finger  = finger;
            fingerData.Index   = index;
            fingerData.Reverse = reverse;

            fingerData.Buffer.Clear();
            fingerData.Points.Clear();

            fingerData.Buffer.Add(finger.ScreenPosition);
            fingerData.Points.Add(finger.ScreenPosition);
            fingerData.Points.Add(finger.ScreenPosition);
        }
        private void FingerSet(LeanFinger finger)
        {
            // Ignore this finger?
            if (IgnoreStartedOverGui == true && finger.StartedOverGui == true)
            {
                return;
            }

            if (IgnoreIsOverGui == true && finger.IsOverGui == true)
            {
                return;
            }

            if (RequiredSelectable != null && RequiredSelectable.IsSelectedBy(finger) == false)
            {
                return;
            }

            // Get link and skip if on cooldown
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            if (fingerData.Cooldown == true)
            {
                return;
            }

            // The scaled delta position magnitude required to register a swipe
            var swipeThreshold = LeanTouch.Instance.SwipeThreshold;

            // The amount of seconds we consider valid for a swipe
            var tapThreshold = LeanTouch.CurrentTapThreshold;

            // Get the scaled delta position between now, and 'swipeThreshold' seconds ago
            var recentDelta = finger.GetSnapshotScreenDelta(tapThreshold);

            // Has the finger recently swiped?
            if (recentDelta.magnitude > swipeThreshold)
            {
                if (CheckSwipe(finger, recentDelta) == true)
                {
                    // Begin cooldown
                    fingerData.CooldownTime = MultipleSwipeDelay;
                    fingerData.Cooldown     = true;
                }
            }
        }
Esempio n. 11
0
        private void HandleFingerDown(LeanFinger finger)
        {
            if (IgnoreStartedOverGui == true && finger.StartedOverGui == true)
            {
                return;
            }
            if (IgnoreIsOverGui == true && finger.IsOverGui == true)
            {
                return;
            }

            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }

            // Get link for this finger and reset
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            fingerData.LastSet          = false;
            fingerData.TotalScaledDelta = Vector2.zero;
        }
Esempio n. 12
0
        private void FingerSet(LeanFinger finger)
        {
            if (MaxLines > 0 && fingerDatas.Count >= MaxLines)
            {
                return;
            }

            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }

            // Get link for this finger and write positions
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            if (fingerData.Line == null)
            {
                fingerData.Line = Instantiate(LinePrefab);
            }

            WritePositions(fingerData.Line, fingerData.Finger);
        }
Esempio n. 13
0
        private void SelectGlobal(LeanSelectable selectable, LeanFinger finger)
        {
            if (waitingForSelection == true)
            {
                LeanFingerData.FindOrCreate(ref fingerDatas, finger);
            }

            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                // Good selection?
                if (MaximumSeparation <= 0.0f || fingerData.LastSelectable == null || Vector3.Distance(fingerData.LastSelectable.transform.position, selectable.transform.position) <= MaximumSeparation)
                {
                    fingerData.LastSelectable = selectable;
                }
                // Too far to select?
                else
                {
                    selectable.Deselect();
                }
            }
        }
Esempio n. 14
0
        private void HandleFingerDown(LeanFinger finger)
        {
            var data = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            data.Flicked = false;
        }
Esempio n. 15
0
        /// <summary>This method allows you to manually add a finger.</summary>
        public void AddFinger(LeanFinger finger)
        {
            var fingerData = LeanFingerData.FindOrCreate(ref fingerDatas, finger);

            fingerData.Flicked = false;
        }