개발중

This commit is contained in:
logonkhi
2025-11-13 20:16:25 +09:00
parent 6920659ed9
commit c98c1d9d9a
42 changed files with 5008 additions and 1854 deletions

View File

@@ -1,11 +1,106 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using Cysharp.Threading.Tasks;
using SHI.modal;
using UnityEngine;
using UnityEngine.UI;
public class ShiPopupSample : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
[SerializeField]
private GameObject blockDetailModalPrefab;
[SerializeField]
private Button openModalButton;
private BlockDetailModal blockDetailModal;
void Start()
{
if (openModalButton != null)
{
openModalButton.onClick.AddListener(() =>
{
if (blockDetailModal == null && blockDetailModalPrefab != null)
{
Canvas canvas = Canvas.FindFirstObjectByType<Canvas>();
Debug.Log($"Creating BlockDetailModal under Canvas:{canvas}");
blockDetailModal = Instantiate(blockDetailModalPrefab, canvas.transform).GetComponent<BlockDetailModal>();
}
blockDetailModal.gameObject.SetActive(true);
SetupData().Forget();
});
}
}
[Serializable]
private class RawScheduleSegment
{
public string ItemId;
public string Start;
public string End;
public float Progress;
public string Type;
}
[Serializable]
private class RawGanttChartData
{
public RawScheduleSegment[] Segments;
}
private async UniTaskVoid SetupData()
{
if (blockDetailModal == null)
{
Debug.LogWarning("BlockDetailModal is not assigned.");
return;
}
string sa = Application.streamingAssetsPath;
string glbPath = Path.Combine(sa, "block.glb");
string jsonPath = Path.Combine(sa, "sample_gantt_data.json");
// Load JSON (editor/standalone path). For Android/WebGL, use UnityWebRequest if needed.
RawGanttChartData raw = null;
try
{
if (File.Exists(jsonPath))
raw = JsonUtility.FromJson<RawGanttChartData>(File.ReadAllText(jsonPath));
else
Debug.LogWarning($"Sample JSON not found: {jsonPath}");
}
catch (Exception ex)
{
Debug.LogError($"Failed reading JSON: {ex}");
}
var gantt = new GanttChartData();
if (raw?.Segments != null)
{
foreach (var s in raw.Segments)
{
DateTime start, end;
if (!DateTime.TryParse(s.Start, null, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out start))
start = DateTime.UtcNow;
if (!DateTime.TryParse(s.End, null, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out end))
end = start.AddDays(1);
gantt.Segments.Add(new ScheduleSegment
{
ItemKey = s.ItemId,
Start = start,
End = end,
Progress = s.Progress,
Type = s.Type ?? string.Empty
});
}
}
Debug.Log($"Loaded blockDetailModal:{blockDetailModal} {gantt.Segments.Count} gantt segments.");
await blockDetailModal.LoadData(glbPath, gantt);
}
}

File diff suppressed because it is too large Load Diff