前段时间公司要求做一款画线游戏,经历了许多坑之后,最终确定使用LineRenderer来做,然后又是一系列的坑,好在最后还是做出来了,给大家分享下代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawLine : MonoBehaviour
{
private GameObject clone;
private LineRenderer line;
private int i;
public GameObject lineRenderPre;
public Material renderMat;
private PolygonCollider2D polygonCollider;
private List<Vector2> points;
private List<Vector3> linePoints;
private List<LineRenderer> lines = new List<LineRenderer>();
private List<GameObject> clones = new List<GameObject>();
private List<List<Vector3>> linePoints_List = new List<List<Vector3>>();
bool hasShot;
public AutomaticLaunch automaticLaunch;
public PhysicsMaterial2D lineMat;
void Start()
{
Application.targetFrameRate = 200;
h