using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Serialization; public class CheckPathTool : MonoBehaviour { public LineRenderer _LineRenderer; public List posList; public bool showPath; private void Awake() { _LineRenderer = this.GetComponent(); _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); } }