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

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