2025-06-16 19:30:01 +09:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UVC.Locale;
|
|
|
|
|
|
using UVC.UI.Commands;
|
2025-06-18 00:16:49 +09:00
|
|
|
|
using UVC.UI.Toolbar.Model;
|
|
|
|
|
|
using UVC.UI.Toolbar.View;
|
2025-06-16 19:30:01 +09:00
|
|
|
|
|
|
|
|
|
|
namespace UVC.UI.Toolbar
|
|
|
|
|
|
{
|
2025-06-18 00:16:49 +09:00
|
|
|
|
public class Toolbar : MonoBehaviour
|
2025-06-16 19:30:01 +09:00
|
|
|
|
{
|
|
|
|
|
|
protected ToolbarModel mainToolbar;
|
|
|
|
|
|
protected ToolbarView mainToolbarView;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 1. 이 GameObject에 연결된 ToolbarView 컴포넌트를 찾습니다.
|
|
|
|
|
|
mainToolbarView = GetComponent<ToolbarView>();
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 만약 현재 GameObject에 없다면, 자식 GameObject들 중에서 ToolbarView 컴포넌트를 찾습니다.
|
|
|
|
|
|
if (mainToolbarView == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
mainToolbarView = GetComponentInChildren<ToolbarView>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
mainToolbar = new ToolbarModel();
|
|
|
|
|
|
|
|
|
|
|
|
// ToolbarView에 프리팹 설정은 ToolbarView 내부에서 처리하거나 Inspector에서 직접 할당합니다.
|
|
|
|
|
|
if (mainToolbarView == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("ToolbarView가 할당되지 않았습니다.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- 툴바 모델 구성 ---
|
|
|
|
|
|
|
|
|
|
|
|
// 요청하신 기능으로 툴바 구성
|
|
|
|
|
|
// 1. 카메라 조절 (RadioButtonGroup)
|
|
|
|
|
|
mainToolbar.AddRadioButton("CameraControlGroup", "Top View", true,
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_camera_top_on",
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_camera_top_off",
|
|
|
|
|
|
(isSelected) => { if (isSelected) Debug.Log("탑뷰 카메라 선택됨"); },
|
|
|
|
|
|
new ActionCommand(() => Debug.Log("탑뷰 카메라 Command 실행")),
|
|
|
|
|
|
"Top View 시점으로 변경합니다.");
|
|
|
|
|
|
mainToolbar.AddRadioButton("CameraControlGroup", "Quarter View", false,
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_camera_quarter_on",
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_camera_quarter_off",
|
|
|
|
|
|
(isSelected) => { if (isSelected) Debug.Log("쿼터뷰 카메라 선택됨"); },
|
|
|
|
|
|
new ActionCommand(() => Debug.Log("쿼터뷰 카메라 Command 실행")),
|
|
|
|
|
|
"Quarter View 시점으로 변경합니다.");
|
|
|
|
|
|
mainToolbar.AddRadioButton("CameraControlGroup", "Front View", false,
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_camera_top_on",
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_camera_top_off",
|
|
|
|
|
|
(isSelected) => { if (isSelected) Debug.Log("프런트뷰 카메라 선택됨"); },
|
|
|
|
|
|
new ActionCommand(() => Debug.Log("프런트뷰 카메라 Command 실행")),
|
|
|
|
|
|
"Front View 시점으로 변경합니다.");
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 구분선
|
|
|
|
|
|
mainToolbar.AddSeparator();
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 객체 선택
|
|
|
|
|
|
mainToolbar.AddStandardButton("선택",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_select_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("객체 선택 버튼 클릭됨")),
|
|
|
|
|
|
"객체를 선택합니다.");
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 객체 이동
|
|
|
|
|
|
mainToolbar.AddStandardButton("이동",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_move_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("객체 이동 버튼 클릭됨")),
|
|
|
|
|
|
"객체를 이동 시킵니다.");
|
|
|
|
|
|
|
|
|
|
|
|
// 5. 객체 회전
|
|
|
|
|
|
mainToolbar.AddStandardButton("회전",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_rotation_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("객체 회전 버튼 클릭됨")),
|
|
|
|
|
|
"객체의 각도를 조절합니다.");
|
|
|
|
|
|
|
|
|
|
|
|
// 6. 객체 크기조절
|
|
|
|
|
|
mainToolbar.AddStandardButton("크기조절",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_scale_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("객체 크기조절 버튼 클릭됨")),
|
|
|
|
|
|
"객체 크기를 조절합니다.");
|
|
|
|
|
|
|
|
|
|
|
|
// 7. 객체 복제
|
|
|
|
|
|
mainToolbar.AddStandardButton("복제",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_copy_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("객체 복제 버튼 클릭됨")),
|
|
|
|
|
|
"객체를 복제 합니다.");
|
|
|
|
|
|
|
|
|
|
|
|
// 8. 객체 삭제
|
|
|
|
|
|
mainToolbar.AddStandardButton("삭제",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_delete_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("객체 삭제 버튼 클릭됨")),
|
|
|
|
|
|
"객체를 삭제 합니다.");
|
|
|
|
|
|
|
|
|
|
|
|
mainToolbar.AddSeparator();
|
|
|
|
|
|
|
|
|
|
|
|
// 9. 화면 캡처
|
|
|
|
|
|
mainToolbar.AddStandardButton("button_capture_screen",
|
2025-06-18 00:16:49 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_capture_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("화면 캡처 버튼 클릭됨")),
|
|
|
|
|
|
"tooltip_capture_screen");
|
|
|
|
|
|
|
|
|
|
|
|
// 10. 화면 녹화 시작/중지 (ToggleButton)
|
|
|
|
|
|
mainToolbar.AddToggleButton("button_record_screen", false,
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_record_on",
|
|
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_record_off",
|
|
|
|
|
|
(isSelected) => Debug.Log($"화면 녹화 상태: {(isSelected ? "녹화 중" : "중지")} (OnToggle 콜백)"),
|
|
|
|
|
|
new ActionCommand<bool>((isRecording) => Debug.Log($"화면 녹화 Command 실행: {(isRecording ? "녹화 시작" : "녹화 중지")}")),
|
|
|
|
|
|
"tooltip_record_screen");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 기존 확장 버튼 (예시로 남겨두거나 필요에 따라 수정/제거)
|
|
|
|
|
|
var expandableBtnModel = mainToolbar.AddExpandableButton("button_brush_size",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
"Prefabs/UI/Toolbar/images/ic_brush_default_white",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
new ActionCommand(() => Debug.Log("브러시 크기 주 버튼 클릭됨 (Command)")),
|
|
|
|
|
|
"붓 사이즈 선택 합니다.");
|
|
|
|
|
|
|
2025-06-17 20:19:06 +09:00
|
|
|
|
var smallBrushCmd = new ActionCommand(() => Debug.Log($"작은 브러시 선택됨"));
|
2025-06-16 19:30:01 +09:00
|
|
|
|
var smallBrush = new ToolbarStandardButton
|
|
|
|
|
|
{
|
|
|
|
|
|
Text = "brush_size_small",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
IconSpritePath = "Prefabs/UI/Toolbar/images/ic_brush_small_white",
|
2025-06-18 00:16:49 +09:00
|
|
|
|
Tooltip = "tooltip_brush_small",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
ClickCommand = smallBrushCmd
|
|
|
|
|
|
};
|
|
|
|
|
|
expandableBtnModel.SubButtons.Add(smallBrush);
|
|
|
|
|
|
|
|
|
|
|
|
var mediumBrush = new ToolbarStandardButton
|
|
|
|
|
|
{
|
|
|
|
|
|
Text = "brush_size_medium",
|
2025-06-17 20:19:06 +09:00
|
|
|
|
IconSpritePath = "Prefabs/UI/Toolbar/images/ic_brush_medium_white",
|
2025-06-18 00:16:49 +09:00
|
|
|
|
Tooltip = "tooltip_brush_medium",
|
2025-06-16 19:30:01 +09:00
|
|
|
|
ClickCommand = new ActionCommand(() => Debug.Log("중간 브러시 선택됨 (Sub-Command 실행)"))
|
|
|
|
|
|
};
|
|
|
|
|
|
expandableBtnModel.SubButtons.Add(mediumBrush);
|
|
|
|
|
|
|
|
|
|
|
|
expandableBtnModel.OnSubButtonSelected = (selectedSubButtonModel) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string localizedSubButtonText = LocalizationManager.Instance != null ? LocalizationManager.Instance.GetString(selectedSubButtonModel.Text) : selectedSubButtonModel.Text;
|
|
|
|
|
|
Debug.Log($"브러시 크기 '{localizedSubButtonText}' 선택됨 (OnSubButtonSelected 콜백). 주 버튼 업데이트 로직 실행 가능.");
|
|
|
|
|
|
};
|
|
|
|
|
|
// --- 툴바 모델 구성 끝 ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ToolbarView 초기화 및 렌더링
|
|
|
|
|
|
mainToolbarView.Initialize(mainToolbar);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 예시: 모델 상태를 코드로 변경하고 UI가 업데이트되는지 테스트
|
|
|
|
|
|
// StartCoroutine(TestModelChange(saveBtnModel, muteToggleModel));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// System.Collections.IEnumerator TestModelChange(ToolbarStandardButton standard, ToolbarToggleButton toggle)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// yield return new WaitForSeconds(2f);
|
|
|
|
|
|
// Debug.Log("모델 변경 테스트: 저장 버튼 비활성화 및 텍스트 변경");
|
|
|
|
|
|
// standard.Text = "저장됨";
|
|
|
|
|
|
// standard.IsEnabled = false;
|
|
|
|
|
|
//
|
|
|
|
|
|
// yield return new WaitForSeconds(2f);
|
|
|
|
|
|
// Debug.Log("모델 변경 테스트: 음소거 토글 상태 변경");
|
|
|
|
|
|
// toggle.IsSelected = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|