Ejemplo n.º 1
0
    private void Update()
    {
        if (updating)
        {
            GameObjectPos currentObj = objects.Peek();
            switch (bodyType)
            {
            case BodyType.Line:
                currentObj.obj.transform.position = (currentObj.startPos + fingertip.transform.position) / 2.0f;
                currentObj.obj.transform.LookAt(fingertip.transform.position);
                currentObj.obj.transform.localScale = new Vector3(0.1f, 0.1f, Vector3.Distance(currentObj.startPos, fingertip.transform.position));
                break;

            case BodyType.Ellipse:
                currentObj.obj.transform.position = (currentObj.startPos + fingertip.transform.position) / 2.0f;
                currentObj.obj.transform.LookAt(fingertip.transform.position);
                currentObj.obj.transform.localScale = new Vector3(0.1f, 0.1f, Vector3.Distance(currentObj.startPos, fingertip.transform.position));
                break;

            case BodyType.Free:
                if (Vector3.Distance(vertPositions[vertPositions.Count - 1], fingertip.transform.position) > 0.03)
                {
                    currLine.AddPoint(fingertip.transform.position);
                    vertPositions.Add(fingertip.transform.position);
                    currLine.GetComponent <MeshCollider>().sharedMesh = currLine.ml;
                }
                break;

            default:
                break;
            }
        }
    }