Example #1
0
    void OnTouching(Vector2 touchPosition)
    {
        if (!IsDrawing)
        {
            return;
        }
        Vector3 point = mainCamera.ScreenToWorldPoint(touchPosition.ToXYVector3() + cameraDistance);

        //ローカル座標に変換
        point = transform.InverseTransformPoint(point);

        //初回は追加して終わり
        if (Line.PointCount <= 0)
        {
            Line.AddLastPoint(point);
            return;
        }

        Vector3 current = point;
        Vector3 last    = Line.LastPoint;

        //近かったら追加しない
        if (IsNearPoint(current, last))
        {
            return;
        }

        Line.AddLastPoint(current, false);

        //長さ制限
        while (Line.Length > maxLineLength)
        {
            Line.RemoveFirstPoint(false);
        }

        Line.Refresh();
    }