Beispiel #1
0
    private void Draw()
    {
        if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) ||
             (Input.GetMouseButton(0))) && touchCount == 0)
        {
            var        Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(Ray, out hit))
            {
                center        = hit.point;
                circumference = center;
                normal        = hit.normal;
                vertices.Add(circumference);
                Vector3 radialRay = circumference - center;
                for (int i = 1; i < npoints; i++)
                {
                    radialRay = Quaternion.AngleAxis(-360f / npoints, normal) * radialRay;
                    vertices.Add(center + radialRay);
                }

                touchCount++;
            }
        }

        else if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) ||
                  (Input.GetMouseButton(0))))
        {
            var        Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(Ray, out hit))
            {
                circumference = hit.point;
                vertices[0]   = circumference;
                Vector3 radialRay = circumference - center;
                for (int i = 1; i < npoints; i++)
                {
                    radialRay   = Quaternion.AngleAxis(-360f / npoints, normal) * radialRay;
                    vertices[i] = center + radialRay;
                }

                GenerateMesh();
            }
        }

        if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended) ||
             (Input.GetMouseButtonUp(0))))
        {
            circleFlag = CircleFlag.INACTIVE;
        }
    }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     circleFlag = CircleFlag.DRAW;
     touchCount = 0;
     name       = "QuadCircle";
 }
Beispiel #3
0
 public void setState(string flag)
 {
     circleFlag = (CircleFlag)System.Enum.Parse(typeof(CircleFlag), flag);
 }