unity基础——线段与拖尾
1、LineRenderer(线段渲染器)
- 为空物体加上组件
- 添加材质 选择默认线段的材质 Default—Line
- Color:可以修改颜色
- Corner Vertices:角顶点 圆滑度
- End Cap Vertices:边缘顶点
线段编辑
1、可以移动线段点的位置,重写画线
2、可以在Scene中自由画线
代码画线:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Linetest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
//设点线段的位置
LineRenderer lineRenderer = GetComponent<LineRenderer>();
lineRenderer.positionCount = 3;
lineRenderer.SetPosition(0,Vector3.zero);
lineRenderer.SetPosition(1,Vector3.one);
lineRenderer.SetPosition(2,Vector3.down);
}
// Update is called once per frame
void Update()
{
}
}