#nullable enable using Cysharp.Threading.Tasks; using SHI.Modal.ISOP; using SHI.Modal.NW; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.UI; /// /// 샘플 장면 드라이버: 버튼 클릭으로 SHI BlockDetail 모달을 생성/표시하고, /// StreamingAssets에서 glb/간트 JSON을 읽어 모달에 전달합니다. /// public class ShiPopupSample : MonoBehaviour { [SerializeField] private GameObject isopModalPrefab; [SerializeField] private GameObject nwModalPrefab; [SerializeField] private Button openISOPModalButton; [SerializeField] private Button openNWModalButton; private ISOPModal? isopModal; private NWModal? nwModal; private void Start() { if (openISOPModalButton != null) { openISOPModalButton.onClick.AddListener(() => { if (isopModalPrefab != null) { isopModal = Instantiate(isopModalPrefab).GetComponent(); } if(isopModal != null) { isopModal.gameObject.SetActive(true); SetupDataISOP().Forget(); } }); } if (openNWModalButton != null) { openNWModalButton.onClick.AddListener(() => { if (nwModalPrefab != null) { nwModal = Instantiate(nwModalPrefab).GetComponent(); } if(nwModal != null) { nwModal.gameObject.SetActive(true); SetupDataNW().Forget(); } }); } } /// /// StreamingAssets에서 샘플 간트 JSON과 모델을 읽어 모달에 적용합니다. /// private async UniTaskVoid SetupDataISOP() { if (isopModal == null) { Debug.LogWarning("BlockDetailModal is not assigned."); return; } string sa = Application.streamingAssetsPath; string glbPath = Path.Combine(sa, "B16VC.glb"); string jsonPath = Path.Combine(sa, "isop_chart_short.json"); Debug.Log($"Loaded blockDetailModal:{isopModal}"); await isopModal.LoadData(new List { Path.Combine(sa, "B11TC.glb"), Path.Combine(sa, "B16VC.glb"), Path.Combine(sa, "E11VC.glb"), Path.Combine(sa, "E41UC.glb"), Path.Combine(sa, "M11UC.glb"), }, jsonPath); } private async UniTaskVoid SetupDataNW() { if (nwModal == null) { Debug.LogWarning("BlockDetailModal is not assigned."); return; } string sa = Application.streamingAssetsPath; string jsonPath = Path.Combine(sa, "nw_chart.json"); Debug.Log($"Loaded blockDetailModal:{nwModal}"); await nwModal.LoadData(new List { Path.Combine(sa, "B11TC.glb"), Path.Combine(sa, "B16VC.glb"), Path.Combine(sa, "E11VC.glb"), Path.Combine(sa, "E41UC.glb"), Path.Combine(sa, "M11UC.glb"), }, jsonPath); } }