Unity划线 DRAWLINE

1. Debug.DrawLine

scene视图中显示,参数坐标为世界坐标,无法设置材质

    for (int i = 1; i < points.Length; i++) {
        Debug.DrawLine (points [i - 1], points [i], Color.white, 5.0f);
    }
2. Gizmos.DrawLine

scene视图中显示,参数为世界坐标,无法设置材质

    void OnDrawGizmos(){
        Gizmos.color = Color.white;
        Gizmos.DrawLine(new Vector3(1, 3, 0), new Vector3(0, 3, 0));
    }
3. LineRenderer

scene&game视图都可见,坐标系可选,可设置材质

    lr = GetComponent ();
    lr.startWidth = 0.05f; 
    lr.endWidth = 0.05f;
    lr.useWorldSpace = false;
    lr.positionCount = points.Length;
    lr.SetPositions (points);

你可能感兴趣的:(Unity划线 DRAWLINE)