PropertyWindow 기능 추가

This commit is contained in:
logonkhi
2025-12-17 11:16:34 +09:00
parent cfd7573ffe
commit beca5f0da5
34 changed files with 3223 additions and 1058 deletions

View File

@@ -1,15 +1,27 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UVC.UI.Tooltip;
using UVC.UI.Window.PropertyWindow;
using UVC.Util;
public class PropertyWindowSample : MonoBehaviour
{
[SerializeField] private PropertyWindow propertyWindow;
[Header("Test Buttons")]
[SerializeField] private Button btnToggleBasicVisibility;
[SerializeField] private Button btnToggleBasicReadOnly;
[SerializeField] private Button btnTogglePropertyVisibility;
[SerializeField] private Button btnTogglePropertyReadOnly;
// 테스트용 상태 변수
private bool _isBasicGroupVisible = true;
private bool _isBasicGroupReadOnly = false;
private bool _isPropertyVisible = true;
private bool _isPropertyReadOnly = false;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
@@ -34,73 +46,210 @@ public class PropertyWindowSample : MonoBehaviour
},
// ========================================
// Basic Properties 그룹 (Order: 2)
// 동적 그룹 표시 테스트용 (Order: 2)
// ========================================
CreateDynamicVisibilityTestGroup(),
// ========================================
// Basic Properties 그룹 (Order: 3)
// ========================================
CreateBasicPropertiesGroup(),
// ========================================
// 중간: 그룹 없는 개별 아이템 (Order: 3)
// 중간: 그룹 없는 개별 아이템 (Order: 4)
// ========================================
new BoolProperty("locked", "Locked", false)
{
Order = 3,
Order = 4,
Description = "잠금 시 수정 불가",
Tooltip = "객체 잠금 토글"
},
// ========================================
// Transform 그룹 (Order: 4)
// Transform 그룹 (Order: 5)
// ========================================
CreateTransformGroup(),
// ========================================
// Date/Time 그룹 (Order: 5, 기본 접힘)
// Date/Time 그룹 (Order: 6, 기본 접힘)
// ========================================
CreateDateTimeGroup(),
// ========================================
// Range 그룹 (Order: 6)
// Range 그룹 (Order: 7)
// ========================================
CreateRangeGroup(),
// ========================================
// Selection 그룹 (Order: 7)
// Selection 그룹 (Order: 8)
// ========================================
CreateSelectionGroup(),
// ========================================
// 하단: 그룹 없는 개별 아이템 (Order: 8)
// 조건부 표시 그룹들 (Order: 9~11)
// ========================================
CreateConditionalGroupA(),
CreateConditionalGroupB(),
CreateConditionalGroupC(),
// ========================================
// 하단: 그룹 없는 개별 아이템 (Order: 12)
// ========================================
new StringProperty("tags", "Tags", "sample, demo")
{
Order = 8,
Order = 12,
Description = "쉼표로 구분된 태그 목록"
}
};
propertyWindow.LoadMixedProperties(entries);
// 초기 상태: 조건부 그룹들 숨김 (Group A만 표시)
propertyWindow.SetGroupVisibility("conditional_b", false);
propertyWindow.SetGroupVisibility("conditional_c", false);
// 값 변경 이벤트 핸들러
propertyWindow.PropertyValueChanged += (sender, e) =>
{
Debug.Log($"[PropertyChanged] Id:{e.PropertyId}, Type:{e.PropertyType}, Value:{e.NewValue}");
};
propertyWindow.PropertyValueChanged += OnPropertyValueChanged;
// 그룹 펼침/접힘 이벤트 핸들러
propertyWindow.GroupExpandedChanged += (sender, e) =>
{
Debug.Log($"[GroupExpanded] Group:{e.Group.GroupName}, Expanded:{e.IsExpanded}");
};
// 테스트 버튼 초기화
SetupTestButtons();
}
/// <summary>
/// 속성 값 변경 이벤트 핸들러
/// </summary>
private void OnPropertyValueChanged(object sender, PropertyValueChangedEventArgs e)
{
Debug.Log($"[PropertyChanged] Id:{e.PropertyId}, Type:{e.PropertyType}, Value:{e.NewValue}");
// 동적 그룹 표시/비표시 테스트
if (e.PropertyId == "display_mode")
{
string selectedMode = e.NewValue as string;
HandleDisplayModeChanged(selectedMode);
}
}
/// <summary>
/// 표시 모드 변경에 따른 그룹 가시성 처리
/// </summary>
private void HandleDisplayModeChanged(string mode)
{
// 모든 조건부 그룹 숨김
propertyWindow.SetGroupVisibility("conditional_a", false);
propertyWindow.SetGroupVisibility("conditional_b", false);
propertyWindow.SetGroupVisibility("conditional_c", false);
// 선택된 모드에 따라 해당 그룹만 표시
switch (mode)
{
case "Mode A":
propertyWindow.SetGroupVisibility("conditional_a", true);
Debug.Log("[DynamicVisibility] Mode A 선택 - Conditional Group A 표시");
break;
case "Mode B":
propertyWindow.SetGroupVisibility("conditional_b", true);
Debug.Log("[DynamicVisibility] Mode B 선택 - Conditional Group B 표시");
break;
case "Mode C":
propertyWindow.SetGroupVisibility("conditional_c", true);
Debug.Log("[DynamicVisibility] Mode C 선택 - Conditional Group C 표시");
break;
case "All":
propertyWindow.SetGroupVisibility("conditional_a", true);
propertyWindow.SetGroupVisibility("conditional_b", true);
propertyWindow.SetGroupVisibility("conditional_c", true);
Debug.Log("[DynamicVisibility] All 선택 - 모든 조건부 그룹 표시");
break;
case "None":
Debug.Log("[DynamicVisibility] None 선택 - 모든 조건부 그룹 숨김");
break;
}
}
/// <summary>
/// 테스트 버튼 설정
/// </summary>
private void SetupTestButtons()
{
// 그룹 가시성 토글 버튼
if (btnToggleBasicVisibility != null)
{
btnToggleBasicVisibility.onClick.AddListener(() =>
{
_isBasicGroupVisible = !_isBasicGroupVisible;
propertyWindow.SetGroupVisibility("basic", _isBasicGroupVisible);
Debug.Log($"[Test] Basic Group Visibility: {_isBasicGroupVisible}");
});
}
// 그룹 ReadOnly 토글 버튼
if (btnToggleBasicReadOnly != null)
{
btnToggleBasicReadOnly.onClick.AddListener(() =>
{
_isBasicGroupReadOnly = !_isBasicGroupReadOnly;
propertyWindow.SetGroupReadOnly("basic", _isBasicGroupReadOnly);
Debug.Log($"[Test] Basic Group ReadOnly: {_isBasicGroupReadOnly}");
});
}
// 개별 속성 가시성 토글 버튼
if (btnTogglePropertyVisibility != null)
{
btnTogglePropertyVisibility.onClick.AddListener(() =>
{
_isPropertyVisible = !_isPropertyVisible;
propertyWindow.SetPropertyVisibility("string_normal", _isPropertyVisible);
Debug.Log($"[Test] Property 'string_normal' Visibility: {_isPropertyVisible}");
});
}
// 개별 속성 ReadOnly 토글 버튼
if (btnTogglePropertyReadOnly != null)
{
btnTogglePropertyReadOnly.onClick.AddListener(() =>
{
_isPropertyReadOnly = !_isPropertyReadOnly;
propertyWindow.SetPropertyReadOnly("int_slider", _isPropertyReadOnly);
Debug.Log($"[Test] Property 'int_slider' ReadOnly: {_isPropertyReadOnly}");
});
}
}
#region Group Factory Methods
/// <summary>
/// 동적 그룹 표시 테스트용 그룹 생성
/// </summary>
private PropertyGroup CreateDynamicVisibilityTestGroup()
{
var group = new PropertyGroup("dynamic_test", "Dynamic Visibility Test", order: 2, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
new ListProperty("display_mode", "Display Mode",
new List<string> { "Mode A", "Mode B", "Mode C", "All", "None" },
"Mode A")
{
Description = "선택한 모드에 따라 아래 조건부 그룹이 표시/숨김됩니다",
Tooltip = "Mode A/B/C: 해당 그룹만 표시, All: 모두 표시, None: 모두 숨김"
}
});
return group;
}
/// <summary>
/// 기본 타입 그룹 생성 (String, Int, Float, Bool)
/// </summary>
private PropertyGroup CreateBasicPropertiesGroup()
{
var group = new PropertyGroup("basic", "Basic Types", order: 2, isExpanded: true);
var group = new PropertyGroup("basic", "Basic Types", order: 3, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
// ---- StringProperty ----
@@ -154,7 +303,7 @@ public class PropertyWindowSample : MonoBehaviour
/// </summary>
private PropertyGroup CreateTransformGroup()
{
var group = new PropertyGroup("transform", "Color & Vectors", order: 4, isExpanded: true);
var group = new PropertyGroup("transform", "Color & Vectors", order: 5, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
// ---- ColorProperty ----
@@ -208,7 +357,7 @@ public class PropertyWindowSample : MonoBehaviour
/// </summary>
private PropertyGroup CreateDateTimeGroup()
{
var group = new PropertyGroup("datetime", "Date & Time Types", order: 5, isExpanded: true);
var group = new PropertyGroup("datetime", "Date & Time Types", order: 6, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
// ---- DateProperty ----
@@ -260,7 +409,7 @@ public class PropertyWindowSample : MonoBehaviour
/// </summary>
private PropertyGroup CreateRangeGroup()
{
var group = new PropertyGroup("range", "Range Types", order: 6, isExpanded: true);
var group = new PropertyGroup("range", "Range Types", order: 7, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
// ---- IntRangeProperty ----
@@ -293,7 +442,7 @@ public class PropertyWindowSample : MonoBehaviour
/// </summary>
private PropertyGroup CreateSelectionGroup()
{
var group = new PropertyGroup("selection", "Selection Types", order: 7, isExpanded: true);
var group = new PropertyGroup("selection", "Selection Types", order: 8, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
// ---- EnumProperty ----
@@ -340,6 +489,78 @@ public class PropertyWindowSample : MonoBehaviour
return group;
}
/// <summary>
/// 조건부 그룹 A 생성 (Mode A 선택 시 표시)
/// </summary>
private PropertyGroup CreateConditionalGroupA()
{
var group = new PropertyGroup("conditional_a", "Conditional Group A (Mode A)", order: 9, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
new StringProperty("mode_a_name", "Mode A Name", "Alpha")
{
Description = "Mode A 전용 속성"
},
new IntProperty("mode_a_value", "Mode A Value", 100)
{
Description = "Mode A 전용 값"
},
new ColorProperty("mode_a_color", "Mode A Color", Color.red)
{
Description = "Mode A 전용 색상"
}
});
return group;
}
/// <summary>
/// 조건부 그룹 B 생성 (Mode B 선택 시 표시)
/// </summary>
private PropertyGroup CreateConditionalGroupB()
{
var group = new PropertyGroup("conditional_b", "Conditional Group B (Mode B)", order: 10, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
new StringProperty("mode_b_name", "Mode B Name", "Beta")
{
Description = "Mode B 전용 속성"
},
new FloatProperty("mode_b_value", "Mode B Value", 50.5f)
{
Description = "Mode B 전용 값"
},
new Vector2Property("mode_b_position", "Mode B Position", new Vector2(100, 200))
{
Description = "Mode B 전용 위치"
}
});
return group;
}
/// <summary>
/// 조건부 그룹 C 생성 (Mode C 선택 시 표시)
/// </summary>
private PropertyGroup CreateConditionalGroupC()
{
var group = new PropertyGroup("conditional_c", "Conditional Group C (Mode C)", order: 11, isExpanded: true);
group.AddItems(new IPropertyItem[]
{
new StringProperty("mode_c_name", "Mode C Name", "Charlie")
{
Description = "Mode C 전용 속성"
},
new BoolProperty("mode_c_enabled", "Mode C Enabled", true)
{
Description = "Mode C 전용 토글"
},
new Vector3Property("mode_c_scale", "Mode C Scale", Vector3.one)
{
Description = "Mode C 전용 스케일"
}
});
return group;
}
#endregion
#region Sample Enums

File diff suppressed because it is too large Load Diff