362 lines
13 KiB
C#
362 lines
13 KiB
C#
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UVC.UI.Tooltip;
|
||
|
|
using UVC.UI.Window.PropertyWindow;
|
||
|
|
using UVC.Util;
|
||
|
|
|
||
|
|
public class PropertyWindowSample : MonoBehaviour
|
||
|
|
{
|
||
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
TooltipManager.Instance.Initialize();
|
||
|
|
|
||
|
|
// 혼용 방식 샘플: 그룹과 개별 아이템을 함께 사용
|
||
|
|
List<IPropertyEntry> entries = new List<IPropertyEntry>
|
||
|
|
{
|
||
|
|
// ========================================
|
||
|
|
// 상단: 그룹 없는 기본 정보 (Order: 0~1)
|
||
|
|
// ========================================
|
||
|
|
new StringProperty("id", "ID", "OBJ_001")
|
||
|
|
{
|
||
|
|
Order = 0,
|
||
|
|
Description = "객체 고유 식별자",
|
||
|
|
IsReadOnly = true
|
||
|
|
},
|
||
|
|
new StringProperty("name", "Name", "Sample Object")
|
||
|
|
{
|
||
|
|
Order = 1,
|
||
|
|
Tooltip = "객체 이름을 입력하세요"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ========================================
|
||
|
|
// Basic Properties 그룹 (Order: 2)
|
||
|
|
// ========================================
|
||
|
|
CreateBasicPropertiesGroup(),
|
||
|
|
|
||
|
|
// ========================================
|
||
|
|
// 중간: 그룹 없는 개별 아이템 (Order: 3)
|
||
|
|
// ========================================
|
||
|
|
new BoolProperty("locked", "Locked", false)
|
||
|
|
{
|
||
|
|
Order = 3,
|
||
|
|
Description = "잠금 시 수정 불가",
|
||
|
|
Tooltip = "객체 잠금 토글"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ========================================
|
||
|
|
// Transform 그룹 (Order: 4)
|
||
|
|
// ========================================
|
||
|
|
CreateTransformGroup(),
|
||
|
|
|
||
|
|
// ========================================
|
||
|
|
// Date/Time 그룹 (Order: 5, 기본 접힘)
|
||
|
|
// ========================================
|
||
|
|
CreateDateTimeGroup(),
|
||
|
|
|
||
|
|
// ========================================
|
||
|
|
// Range 그룹 (Order: 6)
|
||
|
|
// ========================================
|
||
|
|
CreateRangeGroup(),
|
||
|
|
|
||
|
|
// ========================================
|
||
|
|
// Selection 그룹 (Order: 7)
|
||
|
|
// ========================================
|
||
|
|
CreateSelectionGroup(),
|
||
|
|
|
||
|
|
// ========================================
|
||
|
|
// 하단: 그룹 없는 개별 아이템 (Order: 8)
|
||
|
|
// ========================================
|
||
|
|
new StringProperty("tags", "Tags", "sample, demo")
|
||
|
|
{
|
||
|
|
Order = 8,
|
||
|
|
Description = "쉼표로 구분된 태그 목록"
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
PropertyWindow.Instance.LoadMixedProperties(entries);
|
||
|
|
|
||
|
|
// 값 변경 이벤트 핸들러
|
||
|
|
PropertyWindow.Instance.PropertyValueChanged += (sender, e) =>
|
||
|
|
{
|
||
|
|
Debug.Log($"[PropertyChanged] Id:{e.PropertyId}, Type:{e.PropertyType}, Value:{e.NewValue}");
|
||
|
|
};
|
||
|
|
|
||
|
|
// 그룹 펼침/접힘 이벤트 핸들러
|
||
|
|
PropertyWindow.Instance.GroupExpandedChanged += (sender, e) =>
|
||
|
|
{
|
||
|
|
Debug.Log($"[GroupExpanded] Group:{e.Group.GroupName}, Expanded:{e.IsExpanded}");
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
#region Group Factory Methods
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 기본 타입 그룹 생성 (String, Int, Float, Bool)
|
||
|
|
/// </summary>
|
||
|
|
private PropertyGroup CreateBasicPropertiesGroup()
|
||
|
|
{
|
||
|
|
var group = new PropertyGroup("basic", "Basic Types", order: 2, isExpanded: true);
|
||
|
|
group.AddItems(new IPropertyItem[]
|
||
|
|
{
|
||
|
|
// ---- StringProperty ----
|
||
|
|
new StringProperty("string_normal", "String (Normal)", "Hello World")
|
||
|
|
{
|
||
|
|
Description = "일반 문자열 입력",
|
||
|
|
Tooltip = "문자열을 입력하세요"
|
||
|
|
},
|
||
|
|
new StringProperty("string_readonly", "String (ReadOnly)", "Cannot Edit")
|
||
|
|
{
|
||
|
|
Description = "읽기 전용 문자열",
|
||
|
|
IsReadOnly = true
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- IntProperty ----
|
||
|
|
new IntProperty("int_normal", "Int (Normal)", 42)
|
||
|
|
{
|
||
|
|
Description = "일반 정수 입력",
|
||
|
|
Tooltip = "정수 값을 입력하세요"
|
||
|
|
},
|
||
|
|
new IntProperty("int_slider", "Int (Slider)", 50, isSlider: true, minValue: 0, maxValue: 100)
|
||
|
|
{
|
||
|
|
Description = "슬라이더로 표시되는 정수",
|
||
|
|
Tooltip = "0~100 사이의 값"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- FloatProperty ----
|
||
|
|
new FloatProperty("float_normal", "Float (Normal)", 3.14f)
|
||
|
|
{
|
||
|
|
Description = "일반 실수 입력",
|
||
|
|
Tooltip = "실수 값을 입력하세요"
|
||
|
|
},
|
||
|
|
new FloatProperty("float_slider", "Float (Slider)", 0.5f, isSlider: true, minValue: 0f, maxValue: 1f)
|
||
|
|
{
|
||
|
|
Description = "슬라이더로 표시되는 실수",
|
||
|
|
Tooltip = "0.0~1.0 사이의 비율"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- BoolProperty ----
|
||
|
|
new BoolProperty("bool_active", "Bool (Toggle)", true)
|
||
|
|
{
|
||
|
|
Description = "불리언 토글",
|
||
|
|
Tooltip = "활성화/비활성화 상태"
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return group;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 색상 및 벡터 그룹 생성 (Color, Vector2, Vector3)
|
||
|
|
/// </summary>
|
||
|
|
private PropertyGroup CreateTransformGroup()
|
||
|
|
{
|
||
|
|
var group = new PropertyGroup("transform", "Color & Vectors", order: 4, isExpanded: true);
|
||
|
|
group.AddItems(new IPropertyItem[]
|
||
|
|
{
|
||
|
|
// ---- ColorProperty ----
|
||
|
|
new ColorProperty("color_main", "Color", Color.red)
|
||
|
|
{
|
||
|
|
Description = "색상 선택",
|
||
|
|
Tooltip = "컬러 피커로 색상 선택"
|
||
|
|
},
|
||
|
|
new ColorProperty("color_alpha", "Color (with Alpha)", new Color(0.5f, 0.8f, 1f, 0.5f))
|
||
|
|
{
|
||
|
|
Description = "알파(투명도) 포함 색상"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- Vector2Property ----
|
||
|
|
new Vector2Property("vec2_position", "Vector2 (Position)", new Vector2(100, 200))
|
||
|
|
{
|
||
|
|
Description = "2D 좌표",
|
||
|
|
Tooltip = "X, Y 값"
|
||
|
|
},
|
||
|
|
new Vector2Property("vec2_custom", "Vector2 (Custom Labels)", new Vector2(1920, 1080))
|
||
|
|
{
|
||
|
|
Description = "커스텀 라벨",
|
||
|
|
ChildNames = new List<string> { "Width", "Height" }
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- Vector3Property ----
|
||
|
|
new Vector3Property("vec3_position", "Vector3 (Position)", new Vector3(1, 2, 3))
|
||
|
|
{
|
||
|
|
Description = "3D 위치 좌표",
|
||
|
|
Tooltip = "X, Y, Z 값"
|
||
|
|
},
|
||
|
|
new Vector3Property("vec3_rotation", "Vector3 (Rotation)", Vector3.zero)
|
||
|
|
{
|
||
|
|
Description = "오일러 각도 (도)"
|
||
|
|
},
|
||
|
|
new Vector3Property("vec3_scale", "Vector3 (Scale)", Vector3.one)
|
||
|
|
{
|
||
|
|
Description = "로컬 스케일"
|
||
|
|
},
|
||
|
|
new Vector3Property("vec3_custom", "Vector3 (Custom Labels)", new Vector3(255, 128, 64))
|
||
|
|
{
|
||
|
|
Description = "커스텀 라벨",
|
||
|
|
ChildNames = new List<string> { "R", "G", "B" }
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return group;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 날짜/시간 그룹 생성 (Date, DateTime, DateRange, DateTimeRange)
|
||
|
|
/// </summary>
|
||
|
|
private PropertyGroup CreateDateTimeGroup()
|
||
|
|
{
|
||
|
|
var group = new PropertyGroup("datetime", "Date & Time Types", order: 5, isExpanded: false);
|
||
|
|
group.AddItems(new IPropertyItem[]
|
||
|
|
{
|
||
|
|
// ---- DateProperty ----
|
||
|
|
new DateProperty("date_created", "Date (Created)", DateTime.Now.AddDays(-30))
|
||
|
|
{
|
||
|
|
Description = "날짜만 선택",
|
||
|
|
Tooltip = "날짜 선택",
|
||
|
|
IsReadOnly = true
|
||
|
|
},
|
||
|
|
new DateProperty("date_deadline", "Date (Deadline)", DateTime.Now.AddDays(7))
|
||
|
|
{
|
||
|
|
Description = "마감일 선택"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- DateTimeProperty ----
|
||
|
|
new DateTimeProperty("datetime_modified", "DateTime (Modified)", DateTime.Now)
|
||
|
|
{
|
||
|
|
Description = "날짜와 시간 선택",
|
||
|
|
Tooltip = "날짜 + 시간"
|
||
|
|
},
|
||
|
|
new DateTimeProperty("datetime_schedule", "DateTime (Schedule)", DateTime.Now.AddHours(2))
|
||
|
|
{
|
||
|
|
Description = "예약 일시"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- DateRangeProperty ----
|
||
|
|
new DateRangeProperty("daterange_period", "DateRange (Period)",
|
||
|
|
new Tuple<DateTime, DateTime>(DateTime.Now, DateTime.Now.AddMonths(1)))
|
||
|
|
{
|
||
|
|
Description = "날짜 범위 선택",
|
||
|
|
Tooltip = "시작일 ~ 종료일"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- DateTimeRangeProperty ----
|
||
|
|
new DateTimeRangeProperty("datetimerange_hours", "DateTimeRange (Hours)",
|
||
|
|
new Tuple<DateTime, DateTime>(
|
||
|
|
DateTime.Today.AddHours(9),
|
||
|
|
DateTime.Today.AddHours(18)))
|
||
|
|
{
|
||
|
|
Description = "시간대 범위 선택",
|
||
|
|
Tooltip = "시작 시간 ~ 종료 시간"
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return group;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 범위 그룹 생성 (IntRange, FloatRange)
|
||
|
|
/// </summary>
|
||
|
|
private PropertyGroup CreateRangeGroup()
|
||
|
|
{
|
||
|
|
var group = new PropertyGroup("range", "Range Types", order: 6, isExpanded: true);
|
||
|
|
group.AddItems(new IPropertyItem[]
|
||
|
|
{
|
||
|
|
// ---- IntRangeProperty ----
|
||
|
|
new IntRangeProperty("intrange_priority", "IntRange (Priority)", new Tuple<int, int>(1, 10))
|
||
|
|
{
|
||
|
|
Description = "정수 범위",
|
||
|
|
Tooltip = "최소 ~ 최대 정수"
|
||
|
|
},
|
||
|
|
new IntRangeProperty("intrange_level", "IntRange (Level)", new Tuple<int, int>(5, 50))
|
||
|
|
{
|
||
|
|
Description = "레벨 범위"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- FloatRangeProperty ----
|
||
|
|
new FloatRangeProperty("floatrange_temp", "FloatRange (Temperature)", new Tuple<float, float>(20.0f, 25.0f))
|
||
|
|
{
|
||
|
|
Description = "실수 범위",
|
||
|
|
Tooltip = "온도 범위 (°C)"
|
||
|
|
},
|
||
|
|
new FloatRangeProperty("floatrange_percent", "FloatRange (Percent)", new Tuple<float, float>(0.25f, 0.75f))
|
||
|
|
{
|
||
|
|
Description = "백분율 범위"
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return group;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 선택 그룹 생성 (Enum, DropdownList, RadioGroup)
|
||
|
|
/// </summary>
|
||
|
|
private PropertyGroup CreateSelectionGroup()
|
||
|
|
{
|
||
|
|
var group = new PropertyGroup("selection", "Selection Types", order: 7, isExpanded: true);
|
||
|
|
group.AddItems(new IPropertyItem[]
|
||
|
|
{
|
||
|
|
// ---- EnumProperty ----
|
||
|
|
new EnumProperty("enum_status", "Enum (Status)", SampleEnum.Option1)
|
||
|
|
{
|
||
|
|
Description = "열거형 선택",
|
||
|
|
Tooltip = "Enum 드롭다운"
|
||
|
|
},
|
||
|
|
new EnumProperty("enum_layer", "Enum (Layer)", SampleLayer.Default)
|
||
|
|
{
|
||
|
|
Description = "레이어 선택"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- ListProperty (DropdownList) ----
|
||
|
|
new ListProperty("list_category", "DropdownList (Category)",
|
||
|
|
new List<string> { "Category A", "Category B", "Category C", "Category D" },
|
||
|
|
"Category A")
|
||
|
|
{
|
||
|
|
Description = "드롭다운 목록",
|
||
|
|
Tooltip = "문자열 목록에서 선택"
|
||
|
|
},
|
||
|
|
new ListProperty("list_country", "DropdownList (Country)",
|
||
|
|
new List<string> { "Korea", "Japan", "USA", "UK", "Germany", "France" },
|
||
|
|
"Korea")
|
||
|
|
{
|
||
|
|
Description = "국가 선택"
|
||
|
|
},
|
||
|
|
|
||
|
|
// ---- RadioGroupProperty ----
|
||
|
|
new RadioGroupProperty("radio_priority", "RadioGroup (Priority)",
|
||
|
|
new List<string> { "Low", "Medium", "High" },
|
||
|
|
"Medium")
|
||
|
|
{
|
||
|
|
Description = "라디오 버튼 그룹",
|
||
|
|
Tooltip = "하나만 선택 가능"
|
||
|
|
},
|
||
|
|
new RadioGroupProperty("radio_size", "RadioGroup (Size)",
|
||
|
|
new List<string> { "Small", "Medium", "Large", "XLarge" },
|
||
|
|
"Medium")
|
||
|
|
{
|
||
|
|
Description = "크기 선택"
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return group;
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region Sample Enums
|
||
|
|
|
||
|
|
enum SampleEnum
|
||
|
|
{
|
||
|
|
Option1,
|
||
|
|
Option2,
|
||
|
|
Option3
|
||
|
|
}
|
||
|
|
|
||
|
|
enum SampleLayer
|
||
|
|
{
|
||
|
|
Default,
|
||
|
|
UI,
|
||
|
|
Background,
|
||
|
|
Foreground,
|
||
|
|
Effects
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
}
|