You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

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<LineRenderer>();
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<GameObject>("Prefab/MapIcon"), transform);
icon.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = img;
//icon.GetComponent<SpriteRenderer>().material = material;
}
public void Draw() {
//添加图例
DrawIcon();
//绘制线路
DrawLine();
}
}