| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | using System;using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.Serialization;public class CheckPathTool : MonoBehaviour{    public LineRenderer _LineRenderer;    public List<GameObject> posList;    public bool showPath;    private void Awake()    {        _LineRenderer = this.GetComponent<LineRenderer>();        _LineRenderer.enabled = false;    }    private void Start()    {        ActionInstance._Instance.SetCheckPathActive += SetPathActive;    }    private void OnDestroy()    {        ActionInstance._Instance.SetCheckPathActive -= SetPathActive;    }    private void Update()    {        SetPath();    }    public void SetPathActive(bool flag)    {        showPath = false;        _LineRenderer.enabled = flag;    }        public void SetPath()    {        Vector3[] tempPos = new Vector3[posList.Count];        for (int i = 0; i < tempPos.Length; i++)        {            tempPos[i] = posList[i].transform.position;        }        _LineRenderer.positionCount = tempPos.Length;        _LineRenderer.SetPositions(tempPos);    }}
 |