탐색기, 라이브러리, 화면 객체 배치

This commit is contained in:
logonkhi
2025-12-18 20:38:38 +09:00
parent beca5f0da5
commit deeaa9a7ad
102 changed files with 4956 additions and 387 deletions

View File

@@ -182,13 +182,13 @@ namespace UVC.Studio.Config
public class Library
{
/// <summary>스태커 크레인 라이브러리 파일명</summary>
private const string StakerCraneFileName = "LibraryStakerCrane.json";
private const string StakerCraneFileName = "StakerCrane.json";
/// <summary>단일 랙 라이브러리 파일명</summary>
private const string RackSingleFileName = "LibraryRackSingle.json";
private const string RackFileName = "Rack.json";
/// <summary>AGV 라이브러리 파일명</summary>
private const string AGVFileName = "LibraryAGV.json";
private const string AGVFileName = "AGV.json";
/// <summary>스태커 크레인 데이터</summary>
public LibraryStakerCraneData StakerCraneData { get; private set; }
@@ -202,6 +202,28 @@ namespace UVC.Studio.Config
/// <summary>모든 라이브러리 로드 완료 여부</summary>
public bool IsLoaded { get; private set; }
/// <summary>
/// 라이브러리 파일 경로
/// </summary>
public string LibraryPath
{
get
{
if (!useAppDataPath)
{
return Path.Combine(Application.streamingAssetsPath, "Studio", "Library") + "/";
}
else
{
return Path.Combine(Application.persistentDataPath, "Library") + "/";
}
}
}
private bool useAppDataPath = false;
/// <summary>
/// 생성자 - 기본 데이터로 초기화합니다.
/// </summary>
@@ -209,8 +231,9 @@ namespace UVC.Studio.Config
/// 비동기 로드를 사용하려면 생성 후 LoadAllAsync()를 호출하세요.
/// 동기 로드를 원하면 LoadAll()을 호출하세요.
/// </remarks>
public Library()
public Library(bool useAppDataPath = false)
{
this.useAppDataPath = useAppDataPath;
StakerCraneData = new LibraryStakerCraneData();
RackSingleData = new LibraryRackSingleData();
AGVData = new LibraryAGVData();
@@ -267,7 +290,7 @@ namespace UVC.Studio.Config
/// <returns>로드 성공 여부</returns>
public async UniTask<bool> LoadRackSingleAsync(CancellationToken cancellationToken = default)
{
var result = await LoadJsonAsync<LibraryRackSingleData>(RackSingleFileName, cancellationToken);
var result = await LoadJsonAsync<LibraryRackSingleData>(RackFileName, cancellationToken);
RackSingleData = result ?? new LibraryRackSingleData();
return result != null;
}
@@ -296,7 +319,8 @@ namespace UVC.Studio.Config
/// </remarks>
private async UniTask<T> LoadJsonAsync<T>(string fileName, CancellationToken cancellationToken = default) where T : class
{
string path = Path.Combine(Application.streamingAssetsPath, fileName);
string path = Path.Combine(Application.streamingAssetsPath, "Studio", "Library", fileName);
if (useAppDataPath) path = Path.Combine(Application.persistentDataPath, "Library", fileName);
if (!File.Exists(path))
{
@@ -368,7 +392,7 @@ namespace UVC.Studio.Config
/// <returns>로드 성공 여부</returns>
public bool LoadRackSingle()
{
var result = LoadJson<LibraryRackSingleData>(RackSingleFileName);
var result = LoadJson<LibraryRackSingleData>(RackFileName);
RackSingleData = result ?? new LibraryRackSingleData();
return result != null;
}
@@ -393,6 +417,7 @@ namespace UVC.Studio.Config
private T LoadJson<T>(string fileName) where T : class
{
string path = Path.Combine(Application.streamingAssetsPath, fileName);
if (useAppDataPath) path = Path.Combine(Application.persistentDataPath, "Library", fileName);
if (!File.Exists(path))
{
@@ -426,7 +451,7 @@ namespace UVC.Studio.Config
public class LibraryStakerCraneData
{
/// <summary>스태커 크레인 장비 목록</summary>
public List<EquipmentItem> stakerCrane = new();
public List<EquipmentItem> list = new();
}
/// <summary>
@@ -438,8 +463,8 @@ namespace UVC.Studio.Config
[Serializable]
public class LibraryRackSingleData
{
/// <summary>랙 장비 목록 (JSON 키: "AGV")</summary>
public List<EquipmentItem> AGV = new();
/// <summary>랙 장비 목록 (JSON 키: "list")</summary>
public List<EquipmentItem> list = new();
}
/// <summary>
@@ -449,7 +474,7 @@ namespace UVC.Studio.Config
public class LibraryAGVData
{
/// <summary>AGV 장비 목록</summary>
public List<EquipmentItem> AGV = new();
public List<EquipmentItem> list = new();
}
#endregion
@@ -593,12 +618,13 @@ namespace UVC.Studio.Config
public string type;
/// <summary>
/// 속성 값 (문자열)
/// 속성 값
/// </summary>
/// <remarks>
/// 숫자 값 또는 벡터 문자열 (예: "150", "0,0,1")
/// 숫자 값(int, float) 또는 벡터 문자열 (예: 150, 50.5, "0,0,1")
/// JSON에서 숫자 또는 문자열로 저장될 수 있음
/// </remarks>
public string value;
public object value;
/// <summary>
/// 단위
@@ -607,6 +633,42 @@ namespace UVC.Studio.Config
/// 표시용 단위 문자열 (예: "cm", "cm/s", "")
/// </remarks>
public string unit;
/// <summary>
/// value를 float로 반환합니다.
/// </summary>
public float GetFloatValue()
{
if (value == null) return 0f;
if (value is float f) return f;
if (value is double d) return (float)d;
if (value is int i) return i;
if (value is long l) return l;
if (float.TryParse(value.ToString(), out float result)) return result;
return 0f;
}
/// <summary>
/// value를 int로 반환합니다.
/// </summary>
public int GetIntValue()
{
if (value == null) return 0;
if (value is int i) return i;
if (value is long l) return (int)l;
if (value is float f) return (int)f;
if (value is double d) return (int)d;
if (int.TryParse(value.ToString(), out int result)) return result;
return 0;
}
/// <summary>
/// value를 string으로 반환합니다.
/// </summary>
public string GetStringValue()
{
return value?.ToString() ?? string.Empty;
}
}
#endregion