unity3d 简单画线


public GameObject line;

    public Transform[] wayPoint;

    int i;

    void Start()

    {

        i=0;

    }

    void Update()

    {

        if(i<wayPoint.Length-1)

        {

            Vector3 tempPos=(wayPoint[i].position+wayPoint[i+1].position)/2;

            GameObject go=(GameObject)Instantiate(line,tempPos,Quaternion.identity) ;

            go.name=""+i;

            go.transform.right=(go.transform.position-wayPoint[i].position).normalized;

            float distance=Vector3.Distance(wayPoint[i].position,wayPoint[i+1].position);

            go.transform.localScale=new Vector3(distance,0.01f,0.01f);

            i++;

        }

 

    }


你可能感兴趣的:(unity3d 简单画线)