Files
XRLib/README.md
2026-03-05 11:15:26 +09:00

263 lines
11 KiB
Markdown

# XR Library 1.0
Digital Twin 가상공장 개발 용 UGUI 기반 라이브러리입니다. 앞으로 업데이트/관리 되지 않을 것입니다.
UIToolkit 기반 라이브러리(http://xr.flexing.ai:3000/khi/XRLibrary) 사용하세요.
## 주요 기능 및 특징
- **코어 (`UVC.Core`)**
- 애플리케이션의 핵심 로직과 `SingletonScene`과 같은 디자인 패턴을 지원하여 안정적인 개발 기반을 제공합니다.
- **데이터 관리 (`UVC.Data`)**
- **데이터 모델링 (`UVC.Data.Core.DataObject`)**: `DataObject` 클래스는 애플리케이션에서 사용되는 모든 데이터의 기반이 됩니다. `IDataObject` 인터페이스를 구현하며, 데이터의 고유 ID(`Id`), 이름(`Name`), 활성화 상태(`Enable`) 등 공통 속성을 정의합니다. 이를 상속하여 AGV, 설비 등 다양한 종류의 데이터를 표준화된 방식으로 관리할 수 있습니다.
- **데이터 통신**: HTTP, MQTT 등 다양한 프로토콜을 지원하는 Wrapper를 제공하여 외부 시스템과의 데이터 연동을 용이하게 합니다.
- **팩토리 (`UVC.Factory`)**
- **동적 객체 생성**: `AGVManager`와 같이 `DataObject`를 기반으로 씬에 필요한 객체(디지털 트윈, 컴포넌트 등)를 동적으로 생성하고 관리합니다.
- **알람 및 재생**: `AlarmManager`, `PlaybackService` 등을 통해 애플리케이션의 상태 변화에 따른 알람 및 시뮬레이션 재생 기능을 제어합니다.
- **UI 시스템 (`UVC.UI`)**
- **메뉴 & 툴바**: `TopMenuController` 등을 통해 상단 메뉴, 사이드 메뉴, 툴바 등 다양한 형태의 메뉴 시스템을 제공합니다.
- **모달 & 알림**: `Modal` 클래스를 통해 Alert, Confirm, Toast 등 사용자에게 정보를 전달하고 상호작용하는 모달 창을 손쉽게 생성합니다.
- **목록**: 검색, 정렬, 드래그 앤 드롭 기능이 포함된 고성능 목록 UI를 제공합니다.
- **상태 표시**: `UILoading` 로딩 아이콘, `Tooltip` 툴팁 등 사용자에게 현재 상태를 명확하게 전달하는 UI 컴포넌트를 지원합니다.
- **커맨드 패턴 (`UVC.UI.Commands`)**: `ICommand` 인터페이스를 통해 UI 이벤트와 비즈니스 로직을 분리하여 코드의 유지보수성을 높입니다.
- **유틸리티**
- **로깅 (`UVC.Log`)**: `log4net`을 기반으로 한 강력한 로깅 시스템을 제공하여 디버깅 및 운영 효율성을 높입니다.
- **다국어 (`UVC.Locale`)**: 텍스트 기반의 다국어 시스템을 지원하여 손쉽게 글로벌 애플리케이션을 제작할 수 있습니다.
## 사용한 Assets
- **Best MQTT_3.0.4**
- **Best HTTP_3.015**
- **7Zip lzma LZ4 fastLZ zipgzip brotli multiplatform plugins_2.9.2**
- **DOTween Pro_1.0.380**
- **Easy Performant Outline 2D 3D URP HDRP and Built-in Renderer_3.6.2**
- **In-game Debug Console_1.8.2**
- **Shapes2D - Procedural sprites and UI_1.13**
- **Newtonsoft.Json_3.2.1**
- Window > Package Manager > + > Add packacge by name > com.unity.nuget.newtonsoft-json
- **sqlite3.dll**
- sqlite3.dll 파일 Plugins 폴더에 넣기. x86, x64 체크
- **UniTask_2.5.10**
- Window > Package Manager > + > Add packacge from git URL > https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask
- **log4uni_1.2.2**
- https://github.com/HolyShovelSoft/log4uni 다운로드 압축해제 > Assets > Plugins 폴더에 복사
- **NuGetForUnity_4.5.0**
- Window > Package Manager > + > Add packacge from git URL > https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity
- Menu > Nuget > Manage Nuget Packages > MessagePack 3.1.4
- **Runtime File Browser_1.7.4**
- **Unity glTFast 6.14.1**
- **Runtime Transform Gizmos (Lite) 1.0.1**
---
## Runtime Transform Gizmos (Lite) 소스 수정 사항
Grid 크기(`gridSize`)와 Position Snap(`snapPosition`)을 분리하기 위해 RTGLite 소스를 수정하였습니다.
### 수정 목적
- 기존 RTGLite에서는 Position Snap이 `RTGrid.get.settings.cellSize`를 사용하여 Grid 표시 크기와 이동 스냅 간격이 동일한 값을 공유
- Grid 표시 크기와 이동 스냅 간격을 독립적으로 설정할 수 있도록 `GlobalGizmoStyle``positionSnap` 속성 추가
### 1. GlobalGizmoStyle.cs
**파일 경로:** `Assets/Runtime Transform Gizmos (Lite)/Lite/Scripts/Gizmos/GlobalGizmoStyle.cs`
#### 1-1. Private Fields 영역에 필드 추가
**수정 전:**
```csharp
[SerializeField] float mScaleSnap = defaultScaleSnap; // Scale increment used when snapping is enabled
// Buffers used to avoid memory allocations
```
**수정 후:**
```csharp
[SerializeField] float mScaleSnap = defaultScaleSnap; // Scale increment used when snapping is enabled
[SerializeField] float mPositionSnap = defaultPositionSnap; // Position increment used when snapping is enabled
// Buffers used to avoid memory allocations
```
#### 1-2. Public Static Defaults 영역에 기본값 추가
**수정 전:**
```csharp
public static float defaultRotationSnap { get { return 15.0f; } }
public static float defaultScaleSnap { get { return 0.1f; } }
#endregion
```
**수정 후:**
```csharp
public static float defaultRotationSnap { get { return 15.0f; } }
public static float defaultScaleSnap { get { return 0.1f; } }
public static float defaultPositionSnap { get { return 1.0f; } }
#endregion
```
#### 1-3. Public Properties 영역에 속성 추가
**수정 전:**
```csharp
//-----------------------------------------------------------------------------
// Name: scaleSnap (Public Property)
// Desc: Returns or sets the scale increment used when snapping is enabled.
//-----------------------------------------------------------------------------
public float scaleSnap { get { return mScaleSnap; } set { mScaleSnap = Mathf.Max(value, 1e-4f); } }
#endregion
```
**수정 후:**
```csharp
//-----------------------------------------------------------------------------
// Name: scaleSnap (Public Property)
// Desc: Returns or sets the scale increment used when snapping is enabled.
//-----------------------------------------------------------------------------
public float scaleSnap { get { return mScaleSnap; } set { mScaleSnap = Mathf.Max(value, 1e-4f); } }
//-----------------------------------------------------------------------------
// Name: positionSnap (Public Property)
// Desc: Returns or sets the position increment used when snapping is enabled.
//-----------------------------------------------------------------------------
public float positionSnap { get { return mPositionSnap; } set { mPositionSnap = Mathf.Max(value, 1e-4f); } }
#endregion
```
#### 1-4. OnUseDefaults 메서드에 초기화 추가
**수정 전:**
```csharp
// Misc
hoverPadding = defaultHoverPadding;
rotationSensitivity = defaultRotationSensitivity;
scaleSensitivity = defaultScaleSensitivity;
rotationSnap = defaultRotationSnap;
scaleSnap = defaultScaleSnap;
}
```
**수정 후:**
```csharp
// Misc
hoverPadding = defaultHoverPadding;
rotationSensitivity = defaultRotationSensitivity;
scaleSensitivity = defaultScaleSensitivity;
rotationSnap = defaultRotationSnap;
scaleSnap = defaultScaleSnap;
positionSnap = defaultPositionSnap;
}
```
#### 1-5. OnEditorGUI 메서드에 Inspector UI 추가
**수정 전:**
```csharp
// Scale snap
content.text = "Scale snap";
content.tooltip = "Scale increment used when snapping is enabled.";
EditorGUI.BeginChangeCheck();
newFloat = EditorGUILayout.FloatField(content, scaleSnap);
if (EditorGUI.EndChangeCheck())
{
parentObject.OnWillChangeInEditor();
scaleSnap = newFloat;
}
}
}
#endif
```
**수정 후:**
```csharp
// Scale snap
content.text = "Scale snap";
content.tooltip = "Scale increment used when snapping is enabled.";
EditorGUI.BeginChangeCheck();
newFloat = EditorGUILayout.FloatField(content, scaleSnap);
if (EditorGUI.EndChangeCheck())
{
parentObject.OnWillChangeInEditor();
scaleSnap = newFloat;
}
// Position snap
content.text = "Position snap";
content.tooltip = "Position increment used when snapping is enabled.";
EditorGUI.BeginChangeCheck();
newFloat = EditorGUILayout.FloatField(content, positionSnap);
if (EditorGUI.EndChangeCheck())
{
parentObject.OnWillChangeInEditor();
positionSnap = newFloat;
}
}
}
#endif
```
---
### 2. GizmoDrag.cs
**파일 경로:** `Assets/Runtime Transform Gizmos (Lite)/Lite/Scripts/Gizmos/Drag/GizmoDrag.cs`
#### Update 메서드에서 Position Snap 적용
**수정 전:**
```csharp
// Cache data
Vector3 oldTransformPos = mGizmoTransform.position;
var gridSnapDesc = RTGrid.get.snapDesc;
// If we are using absolute snapping and we are move-snapping along a single axis,
```
**수정 후:**
```csharp
// Cache data
Vector3 oldTransformPos = mGizmoTransform.position;
var gridSnapDesc = RTGrid.get.snapDesc;
// Use globalGizmoStyle.positionSnap for cell size instead of grid cell size
float posSnap = RTGizmos.get.skin.globalGizmoStyle.positionSnap;
gridSnapDesc.cellSize = new Vector3(posSnap, posSnap, posSnap);
// If we are using absolute snapping and we are move-snapping along a single axis,
```
---
### 사용 방법
```csharp
using RTGLite;
// Grid 표시 크기 설정 (Grid 시각적 크기)
RTGrid.get.settings.cellSize = new Vector3(1f, 1f, 1f);
// Position Snap 설정 (이동 스냅 간격)
RTGizmos.get.skin.globalGizmoStyle.positionSnap = 0.5f;
// Rotation Snap 설정 (회전 스냅 간격, 기존 기능)
RTGizmos.get.skin.globalGizmoStyle.rotationSnap = 15f;
// Scale Snap 설정 (스케일 스냅 간격, 기존 기능)
RTGizmos.get.skin.globalGizmoStyle.scaleSnap = 0.1f;
// 스냅 활성화/비활성화
RTGizmos.get.snapEnabled = true;
```
### 설정 속성 요약
| 설정 | 용도 | RTGizmos 속성 |
|------|------|---------------|
| `gridSize` | Grid 표시 크기 | `RTGrid.get.settings.cellSize` |
| `snapPosition` | 이동 스냅 간격 | `RTGizmos.get.skin.globalGizmoStyle.positionSnap` |
| `snapRotation` | 회전 스냅 간격 | `RTGizmos.get.skin.globalGizmoStyle.rotationSnap` |
| `snapScale` | 스케일 스냅 간격 | `RTGizmos.get.skin.globalGizmoStyle.scaleSnap` |