StyleGuide Sample 완료
This commit is contained in:
@@ -124,6 +124,61 @@ namespace UVC.Sample.UIToolkit
|
||||
openPickerAsyncBtn.style.marginBottom = 10;
|
||||
container.Add(openPickerAsyncBtn);
|
||||
|
||||
// Alpha 프리셋 버튼들
|
||||
var alphaPresetLabel = new Label("Alpha Presets:");
|
||||
alphaPresetLabel.style.color = Color.white;
|
||||
alphaPresetLabel.style.marginTop = 10;
|
||||
alphaPresetLabel.style.marginBottom = 5;
|
||||
container.Add(alphaPresetLabel);
|
||||
|
||||
var alphaPresetRow = new VisualElement();
|
||||
alphaPresetRow.style.flexDirection = FlexDirection.Row;
|
||||
alphaPresetRow.style.marginBottom = 10;
|
||||
|
||||
// Alpha 값이 다른 프리셋 버튼들
|
||||
float[] alphaValues = { 1.0f, 0.75f, 0.5f, 0.25f };
|
||||
foreach (var alpha in alphaValues)
|
||||
{
|
||||
var alphaBtn = new Button(() => SetColorWithAlpha(alpha));
|
||||
alphaBtn.style.width = 50;
|
||||
alphaBtn.style.height = 28;
|
||||
alphaBtn.style.marginRight = 5;
|
||||
alphaBtn.style.backgroundColor = new Color(0.3f, 0.3f, 0.3f);
|
||||
alphaBtn.style.borderTopLeftRadius = 4;
|
||||
alphaBtn.style.borderTopRightRadius = 4;
|
||||
alphaBtn.style.borderBottomLeftRadius = 4;
|
||||
alphaBtn.style.borderBottomRightRadius = 4;
|
||||
alphaBtn.text = $"{(int)(alpha * 100)}%";
|
||||
alphaBtn.style.fontSize = 11;
|
||||
alphaPresetRow.Add(alphaBtn);
|
||||
}
|
||||
|
||||
container.Add(alphaPresetRow);
|
||||
|
||||
// Alpha 활성화/비활성화 직접 호출 버튼들
|
||||
var alphaControlLabel = new Label("Alpha Control Examples:");
|
||||
alphaControlLabel.style.color = Color.white;
|
||||
alphaControlLabel.style.marginTop = 5;
|
||||
alphaControlLabel.style.marginBottom = 5;
|
||||
container.Add(alphaControlLabel);
|
||||
|
||||
var alphaControlRow = new VisualElement();
|
||||
alphaControlRow.style.flexDirection = FlexDirection.Row;
|
||||
alphaControlRow.style.marginBottom = 10;
|
||||
|
||||
var withAlphaBtn = new Button(OpenColorPickerWithAlpha) { text = "With Alpha" };
|
||||
withAlphaBtn.style.height = 28;
|
||||
withAlphaBtn.style.flexGrow = 1;
|
||||
withAlphaBtn.style.marginRight = 5;
|
||||
alphaControlRow.Add(withAlphaBtn);
|
||||
|
||||
var withoutAlphaBtn = new Button(OpenColorPickerWithoutAlpha) { text = "Without Alpha" };
|
||||
withoutAlphaBtn.style.height = 28;
|
||||
withoutAlphaBtn.style.flexGrow = 1;
|
||||
alphaControlRow.Add(withoutAlphaBtn);
|
||||
|
||||
container.Add(alphaControlRow);
|
||||
|
||||
// 프리셋 색상 버튼들
|
||||
var presetLabel = new Label("Preset Colors:");
|
||||
presetLabel.style.color = Color.white;
|
||||
@@ -169,6 +224,58 @@ namespace UVC.Sample.UIToolkit
|
||||
_currentPicker.OnColorSelected += OnColorSelected;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alpha 채널 활성화 상태로 컬러 피커 열기
|
||||
/// </summary>
|
||||
private void OpenColorPickerWithAlpha()
|
||||
{
|
||||
if (_root == null || _currentPicker != null) return;
|
||||
|
||||
// useAlpha = true로 명시적 호출
|
||||
_currentPicker = UTKColorPicker.Show(_root, _currentColor, "Select Color (Alpha ON)", useAlpha: true);
|
||||
|
||||
_currentPicker.OnColorChanged += OnColorChanged;
|
||||
_currentPicker.OnColorSelected += OnColorSelected;
|
||||
|
||||
Debug.Log("[Sample] ColorPicker opened with Alpha channel enabled");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alpha 채널 비활성화 상태로 컬러 피커 열기
|
||||
/// </summary>
|
||||
private void OpenColorPickerWithoutAlpha()
|
||||
{
|
||||
if (_root == null || _currentPicker != null) return;
|
||||
|
||||
// useAlpha = false로 명시적 호출
|
||||
_currentPicker = UTKColorPicker.Show(_root, _currentColor, "Select Color (Alpha OFF)", useAlpha: false);
|
||||
|
||||
_currentPicker.OnColorChanged += OnColorChanged;
|
||||
_currentPicker.OnColorSelected += OnColorSelected;
|
||||
|
||||
Debug.Log("[Sample] ColorPicker opened without Alpha channel");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 색상의 Alpha 값을 변경
|
||||
/// </summary>
|
||||
private void SetColorWithAlpha(float alpha)
|
||||
{
|
||||
_currentColor = new Color(_currentColor.r, _currentColor.g, _currentColor.b, alpha);
|
||||
|
||||
if (_colorPreview != null)
|
||||
{
|
||||
_colorPreview.style.backgroundColor = _currentColor;
|
||||
}
|
||||
|
||||
if (_colorLabel != null)
|
||||
{
|
||||
_colorLabel.text = ColorToHex(_currentColor);
|
||||
}
|
||||
|
||||
Debug.Log($"[Sample] Alpha set to {(int)(alpha * 100)}% - Color: {ColorToHex(_currentColor)}");
|
||||
}
|
||||
|
||||
private async UniTaskVoid OpenColorPickerAsync()
|
||||
{
|
||||
if (_root == null) return;
|
||||
|
||||
Reference in New Issue
Block a user