コード例 #1
0
 void FixedUpdate()
 {
     if (!Drawing)
     {
         waitTime += Time.deltaTime;
         if (waitTime > MAX_TIME && pens.Count > 0)
         {
             AddWord();
             waitTime = 0;
         }
     }
     if (Input.GetMouseButtonDown(0))
     {
         pen = new Pen(PenCount++);
         i   = 0;
         Init(pen);
     }
     if (Input.GetMouseButton(0))
     {
         Vector3 point = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0) - startPoint;
         if (!pen.GetPoints().Contains(point))
         {
             pen.AddPoint(point);
             SetData(i, point);
             i++;
         }
         waitTime = 0;
     }
     if (Input.GetMouseButtonUp(0))
     {
         AddPen(pen);
     }
 }
コード例 #2
0
ファイル: PenBehaviour.cs プロジェクト: Y-dc/GeoSpace
    void Update()
    {
        if (!Drawing)
        {
            waitTime += Time.deltaTime;
            if (waitTime > MAX_TIME && pens.Count > 0)
            {
                AddWord();
                waitTime = 0;
            }
        }
        if (Input.GetMouseButtonDown(0))
        {
            pen = new Pen(PenCount++);
            i   = 0;
            Init(pen);
        }
        if (Input.GetMouseButton(0))
        {
            Vector3 point = new Vector3(0, 0, 0);
            //Vector3 point = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
            //point = ScaleHandwritingPoint(point);
            if (Drawing)
            {
                point = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0) - startPoint;
                Vector3 fixPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
                fixPoint = ScaleHandwritingPoint(fixPoint);
                if (!pen.GetPoints().Contains(fixPoint))
                {
                    pen.AddPoint(fixPoint);
                    SetData(i, fixPoint);
                    i++;
                }
            }
            else
            {
                point = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
                point = ScaleHandwritingPoint(point);
                if (!pen.GetPoints().Contains(point))
                {
                    pen.AddPoint(point);
                    SetData(i, point);
                    i++;
                }
            }

            /*
             * if (!pen.GetPoints().Contains(point))
             * {
             *  pen.AddPoint(point);
             *  SetData(i, point);
             *  i++;
             * }
             */
            waitTime = 0;
        }
        if (Input.GetMouseButtonUp(0))
        {
            AddPen(pen);
        }
    }
コード例 #3
0
    void Update()
    {
        if (!Drawing)
        {
            waitTime += Time.deltaTime;
            if (waitTime > MAX_TIME && pens.Count > 0)
            {
                if (geometry.Type == GeometryType.Function)
                {
                    AddFomula();
                }
                else
                {
                    AddWord();
                }
                waitTime = 0;
            }
        }
        //生成新笔迹
        if (Input.GetMouseButtonDown(0))
        {
            pen = new Pen(PenCount++);
            i   = 0;
            Init(pen);
        }
        if (Input.GetMouseButton(0))
        {
            Vector3 point = new Vector3(0, 0, 0);
            if (Drawing)
            {
                point = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0) - startPoint;
                Vector3 fixPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
                fixPoint = ScaleHandwritingPoint(fixPoint);
                if (!pen.GetPoints().Contains(fixPoint))
                {
                    pen.AddPoint(fixPoint);
                    SetData(i, fixPoint);
                    i++;
                }
            }
            else
            {
                if (IsTouchDevice())
                {
                    if (Input.touchCount > 0)
                    {
                        point = new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, 0);
                    }
                }
                else
                {
                    point = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
                }
                point = ScaleHandwritingPoint(point);

                if (!pen.GetPoints().Contains(point))
                {
                    pen.AddPoint(point);
                    SetData(i, point);
                    i++;
                }
            }
            waitTime = 0;
        }
        if (Input.GetMouseButtonUp(0))
        {
            //添加笔迹并检查是否是√或O
            AddPen(pen);

            /*if (geometry != null && geometry.Type == GeometryType.Function)
             * {
             *  int res = CheckPen(pen);
             *  if (res == 1)
             *  {
             *      if (geometry != null && geometry.Type == GeometryType.Function)
             *      {
             *          AddFomula();
             *      }
             *      else
             *      {
             *          AddWord();
             *      }
             *  }
             *  else if (res == 2)
             *  {
             *      Debug.Log("测试到圈");
             *      AddChange();
             *  }
             * }*/
        }
    }