Exemple #1
0
        /// <summary>
        /// Register this point only if the point list is empty or current point
        /// is far enough than the last point. This ensures that the multi stroke looks
        /// good on the screen. Moreover, it is good to not overpopulate the screen
        /// with so much points.
        /// </summary>
        private void RegisterPoint(Vector2 point)
        {
            // Converting a point on screen coordinates to editor coordinates
            screenPoint = new Vector3(point.x, Screen.height - point.y);

            switch (limitType)
            {
            case GestureLimitType.ClampToArea:

                if (!limitedDrawAreaRect.Contains(point))
                {
                    point = limitedDrawAreaRect.Clamp(point);
                }

                break;

            case GestureLimitType.IgnoreOutside:

                if (!limitedDrawAreaRect.Contains(point))
                {
                    return;
                }

                break;
            }

            if (Vector2.Distance(point, lastPoint) > distanceBetweenPoints)
            {
                points.Add(new Point(currentStrokeID, screenPoint.x, screenPoint.y));
                lastPoint = point;

                currentStrokeRenderer.SetVertexCount(++vertexCount);
                currentStrokeRenderer.SetPosition(vertexCount - 1, Utility.WorldCoordinateForGesturePoint(point));
            }
        }