2025-11-27 19:26:01 +09:00
|
|
|
#nullable enable
|
2025-11-14 19:54:04 +09:00
|
|
|
using Cysharp.Threading.Tasks;
|
2025-11-27 13:41:37 +09:00
|
|
|
using SHI.Modal.ISOP;
|
2025-11-27 19:26:01 +09:00
|
|
|
using SHI.Modal.NW;
|
2025-11-13 20:16:25 +09:00
|
|
|
using System.IO;
|
2025-11-12 12:28:17 +09:00
|
|
|
using UnityEngine;
|
2025-11-13 20:16:25 +09:00
|
|
|
using UnityEngine.UI;
|
2025-11-12 12:28:17 +09:00
|
|
|
|
2025-11-14 19:54:04 +09:00
|
|
|
/// <summary>
|
|
|
|
|
/// 샘플 장면 드라이버: 버튼 클릭으로 SHI BlockDetail 모달을 생성/표시하고,
|
|
|
|
|
/// StreamingAssets에서 glb/간트 JSON을 읽어 모달에 전달합니다.
|
|
|
|
|
/// </summary>
|
2025-11-12 12:28:17 +09:00
|
|
|
public class ShiPopupSample : MonoBehaviour
|
|
|
|
|
{
|
2025-11-13 20:16:25 +09:00
|
|
|
[SerializeField]
|
2025-11-27 19:26:01 +09:00
|
|
|
private GameObject isopModalPrefab;
|
2025-11-13 20:16:25 +09:00
|
|
|
|
|
|
|
|
[SerializeField]
|
2025-11-27 19:26:01 +09:00
|
|
|
private GameObject nwModalPrefab;
|
2025-11-13 20:16:25 +09:00
|
|
|
|
2025-11-27 19:26:01 +09:00
|
|
|
[SerializeField]
|
|
|
|
|
private Button openISOPModalButton;
|
|
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
private Button openNWModalButton;
|
|
|
|
|
|
|
|
|
|
private ISOPModal? isopModal;
|
|
|
|
|
private NWModal? nwModal;
|
2025-11-13 20:16:25 +09:00
|
|
|
|
2025-11-14 19:54:04 +09:00
|
|
|
private void Start()
|
2025-11-12 12:28:17 +09:00
|
|
|
{
|
2025-11-27 19:26:01 +09:00
|
|
|
if (openISOPModalButton != null)
|
2025-11-13 20:16:25 +09:00
|
|
|
{
|
2025-11-27 19:26:01 +09:00
|
|
|
openISOPModalButton.onClick.AddListener(() =>
|
2025-11-14 19:54:04 +09:00
|
|
|
{
|
2025-11-27 19:26:01 +09:00
|
|
|
if (isopModalPrefab != null)
|
|
|
|
|
{
|
|
|
|
|
isopModal = Instantiate(isopModalPrefab).GetComponent<ISOPModal>();
|
|
|
|
|
}
|
2025-11-27 13:41:37 +09:00
|
|
|
|
|
|
|
|
if(isopModal != null)
|
2025-11-13 20:16:25 +09:00
|
|
|
{
|
2025-11-27 13:41:37 +09:00
|
|
|
isopModal.gameObject.SetActive(true);
|
2025-11-27 19:26:01 +09:00
|
|
|
SetupDataISOP().Forget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (openNWModalButton != null)
|
|
|
|
|
{
|
|
|
|
|
openNWModalButton.onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
if (nwModalPrefab != null)
|
|
|
|
|
{
|
|
|
|
|
nwModal = Instantiate(nwModalPrefab).GetComponent<NWModal>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(nwModal != null)
|
|
|
|
|
{
|
|
|
|
|
nwModal.gameObject.SetActive(true);
|
|
|
|
|
SetupDataNW().Forget();
|
2025-11-13 20:16:25 +09:00
|
|
|
}
|
2025-11-27 13:41:37 +09:00
|
|
|
|
2025-11-13 20:16:25 +09:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-17 19:30:05 +09:00
|
|
|
|
2025-11-13 20:16:25 +09:00
|
|
|
|
2025-11-14 19:54:04 +09:00
|
|
|
/// <summary>
|
|
|
|
|
/// StreamingAssets에서 샘플 간트 JSON과 모델을 읽어 모달에 적용합니다.
|
|
|
|
|
/// </summary>
|
2025-11-27 19:26:01 +09:00
|
|
|
private async UniTaskVoid SetupDataISOP()
|
2025-11-13 20:16:25 +09:00
|
|
|
{
|
2025-11-27 13:41:37 +09:00
|
|
|
if (isopModal == null)
|
2025-11-13 20:16:25 +09:00
|
|
|
{
|
|
|
|
|
Debug.LogWarning("BlockDetailModal is not assigned.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string sa = Application.streamingAssetsPath;
|
|
|
|
|
string glbPath = Path.Combine(sa, "block.glb");
|
2025-11-27 13:41:37 +09:00
|
|
|
string jsonPath = Path.Combine(sa, "isop_chart_short.json");
|
2025-11-13 20:16:25 +09:00
|
|
|
|
2025-11-17 19:30:05 +09:00
|
|
|
|
2025-11-27 13:41:37 +09:00
|
|
|
Debug.Log($"Loaded blockDetailModal:{isopModal}");
|
|
|
|
|
await isopModal.LoadData(glbPath, jsonPath);
|
2025-11-13 20:16:25 +09:00
|
|
|
}
|
2025-11-27 19:26:01 +09:00
|
|
|
|
|
|
|
|
private async UniTaskVoid SetupDataNW()
|
|
|
|
|
{
|
|
|
|
|
if (nwModal == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("BlockDetailModal is not assigned.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string sa = Application.streamingAssetsPath;
|
|
|
|
|
string glbPath = Path.Combine(sa, "block.glb");
|
|
|
|
|
string jsonPath = Path.Combine(sa, "nw_chart.json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Debug.Log($"Loaded blockDetailModal:{nwModal}");
|
|
|
|
|
await nwModal.LoadData(glbPath, jsonPath);
|
|
|
|
|
}
|
2025-11-12 12:28:17 +09:00
|
|
|
}
|