라이브러리 정리
This commit is contained in:
156
Assets/Sample/ShiPopupSample.cs
Normal file
156
Assets/Sample/ShiPopupSample.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
#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;
|
||||
using UVC.GLTF;
|
||||
|
||||
/// <summary>
|
||||
/// 샘플 장면 드라이버: 버튼 클릭으로 SHI BlockDetail 모달을 생성/표시하고,
|
||||
/// StreamingAssets에서 glb/간트 JSON을 읽어 모달에 전달합니다.
|
||||
/// </summary>
|
||||
public class ShiPopupSample : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject isopModalPrefab;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject nwModalPrefab;
|
||||
|
||||
[SerializeField]
|
||||
private Button openISOPModalButton;
|
||||
|
||||
[SerializeField]
|
||||
private Button openNWModalButton;
|
||||
|
||||
[SerializeField]
|
||||
private Button loadGLTFMultiLODButton;
|
||||
|
||||
[SerializeField]
|
||||
private Button loadGLTFButton;
|
||||
|
||||
[SerializeField]
|
||||
private Transform lodRoot;
|
||||
|
||||
[SerializeField]
|
||||
private Transform lodRoot2;
|
||||
|
||||
private ISOPModal? isopModal;
|
||||
private NWModal? nwModal;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (openISOPModalButton != null)
|
||||
{
|
||||
openISOPModalButton.onClick.AddListener(() =>
|
||||
{
|
||||
if (isopModalPrefab != null)
|
||||
{
|
||||
isopModal = Instantiate(isopModalPrefab).GetComponent<ISOPModal>();
|
||||
}
|
||||
|
||||
if(isopModal != null)
|
||||
{
|
||||
isopModal.gameObject.SetActive(true);
|
||||
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();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if(loadGLTFMultiLODButton != null)
|
||||
{
|
||||
loadGLTFMultiLODButton.onClick.AddListener(() =>
|
||||
{
|
||||
string sa = Application.streamingAssetsPath;
|
||||
GLTFImporter.ImportWithLOD(new List<string> {
|
||||
Path.Combine(sa, "model_lod0.glb"),
|
||||
Path.Combine(sa, "model_lod1.glb"),
|
||||
Path.Combine(sa, "model_lod2.glb"),
|
||||
Path.Combine(sa, "model_lod3.glb"),
|
||||
}, lodRoot).Forget();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if(loadGLTFButton != null)
|
||||
{
|
||||
loadGLTFButton.onClick.AddListener(() =>
|
||||
{
|
||||
string sa = Application.streamingAssetsPath;
|
||||
GLTFImporter.ImportFromFile(Path.Combine(sa, "model_with_lod.glb"), lodRoot2).Forget();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// StreamingAssets에서 샘플 간트 JSON과 모델을 읽어 모달에 적용합니다.
|
||||
/// </summary>
|
||||
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<string> {
|
||||
Path.Combine(sa, "model_with_lod.glb"),
|
||||
Path.Combine(sa, "model_with_lod2.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<string> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user