using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class WRJMinpMap : MonoBehaviour { public Transform points;//路线顶点 public Sprite img;//图标 LineRenderer lineRender; public Material material; void Start() { } void DrawLine() { lineRender = gameObject.AddComponent(); lineRender.startWidth = 10; lineRender.endWidth = 10; lineRender.positionCount = points.childCount; lineRender.material = material; for (int i = 0; i < points.childCount; i++) { lineRender.SetPosition(i, points.GetChild(i).position +new Vector3(0,100,0)); } } void DrawIcon() { GameObject icon = Instantiate(Resources.Load("Prefab/MapIcon"), transform); icon.transform.GetChild(0).GetComponent().sprite = img; //icon.GetComponent().material = material; } public void Draw() { //添加图例 DrawIcon(); //绘制线路 DrawLine(); } }