Пример #1
0
        /// <summary>
        /// Learns a template from the given points
        /// </summary>
        /// <exception cref="ArgumentNullException">Name cannot be empty or null</exception>
        public void Learn(string name, params Vector2[] points)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("Name cannot be empty or null!");
            }
            if (ContainsName(name))
            {
                return;
            }

            templates.Add(new Template(
                              name, ShapeRecognizer.DoEverything(new List <Vector2>(points))
                              ));
        }
Пример #2
0
        /// <summary>
        /// Called when the touch ended
        /// </summary>
        private void TouchEnded(Vector2 pos)
        {
            processedPoints = ShapeRecognizer.DoEverything(points);

            tempLineRenderer.positionCount = points.Count;
            for (int i = 0; i < points.Count; i++)
            {
                tempLineRenderer.SetPosition(i, points[i] * Camera.main.pixelHeight / 2f);
            }

            var _template = ShapeRecognizer.GetBestMatch(processedPoints, templateGroup);

            // Recognize swipe if it's in the template provided by user
            if (_template.Name == "Swipe")
            {
                Swipe(points[0], points[points.Count - 1]);
            }
        }