/// <summary>
/// 脚本位置:Path身上
/// </summary>
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PathTrail : MonoBehaviour
{
// 是否显示场景信息
public bool ShowTrail = false;
// 一个列表用于保存多条路径
private GameObject[] Paths;
// 一个字典用于保存多条路径点
private Dictionary<GameObject, List<Transform>> PathNodes = new Dictionary<GameObject, List<Transform>>();
void Awake()
{
BuildPath();
}
// 创建路径 - 可以在编辑状态下执行BuildPath
[ContextMenu("BuildPath")]
public void BuildPath()
{
PathNodes.Clear();
// 找到path1和path2
Paths = GameObject.FindGameObjectsWithTag("path");
for (int i = 0; i <Paths.Length; i++)
{ // 调用FindPathNode方法,查找path1中的所有路点
PathNodes.Add(Paths[i], FindPathNode(Paths[i].transform));
【Unity】中用路点画线
最新推荐文章于 2023-05-19 16:14:11 发布