using Gameplay.Unit; using PhxhSDK; using UnityEngine; namespace Code.Scripts.Gameplay.PlaneShadow { public class ViewPlaneShadow { public GameUnit followUnit; private GameObject _rootObj; public bool needRemove { get; private set; } public ViewPlaneShadow(GameUnit followUnit) { this.followUnit = followUnit; needRemove = false; } public void CreateView(string modelPath, Transform parent) { var sampleObj = AssetManager.Instance.GetPreLoadResult(modelPath); if (sampleObj == null) { Debug.LogError("CreateView failed, sampleObj is null"); return; } _rootObj = Object.Instantiate(sampleObj, parent); _rootObj.transform.position = new Vector3(-1000, -1000, -1000); } public void ViewUpdate() { if (followUnit.needRemove) { needRemove = true; return; } if (_rootObj == null) { return; } if (!followUnit.Node.GameObject.activeSelf) { if (_rootObj.activeSelf) { _rootObj.SetActive(false); } return; } if (!_rootObj.activeSelf) { _rootObj.SetActive(true); } _rootObj.transform.position = followUnit.transform.position; } public void Dispose() { if (_rootObj != null) { Object.Destroy(_rootObj); _rootObj = null; } } } }