using System.Collections; using System.Collections.Generic; using UnityEngine; public class NavPathController : MonoBehaviour { public List pathObjects = new List(); public List pathSteps = new List(); private int GetCurrentStep() { return pathSteps.IndexOf(GameManager.ProcessMgr.d_Scheme.CurrentProcess.CurrentSubProcess.CurrentSubProcessStep.subProcessStepName); } // Start is called before the first frame update void Start() { // 初始化时隐藏所有箭头 foreach (var obj in pathObjects) { if (obj != null) { obj.SetActive(false); } } // 根据当前步骤显示对应的箭头(如果有的话) UpdateArrowVisibility(); } public void HideAllArrows() { // 隐藏所有箭头 foreach (var obj in pathObjects) { if (obj != null) { obj.SetActive(false); } } } // Update is called once per frame void Update() { if (GameManager.RunModelMgr.ModeType == E_ModeType.Study) { // 检查当前步骤是否改变,并更新箭头显示 int currentStep = GetCurrentStep(); if (currentStep > 0 && (currentStep - 1) < pathObjects.Count) { HideAllArrows(); // 显示当前步骤对应的箭头 pathObjects[currentStep - 1].SetActive(true); } else { HideAllArrows(); } } } // 一个单独的方法用于更新箭头的可见性,可以在其他地方调用 private void UpdateArrowVisibility() { if (GameManager.RunModelMgr.ModeType == E_ModeType.Study) { int currentStep = GetCurrentStep(); if (currentStep > 0 && (currentStep - 1) < pathObjects.Count) { HideAllArrows(); // 显示当前步骤对应的箭头 pathObjects[currentStep - 1].SetActive(true); } else { HideAllArrows(); } } } }