using UnityEngine; using UnityEditor; using KindRetargeting.Remote; namespace KindRetargeting.Editor { [CustomEditor(typeof(RetargetingRemoteController))] public class RetargetingRemoteControllerEditor : UnityEditor.Editor { private SerializedProperty wsPortProp; private SerializedProperty autoStartProp; private SerializedProperty registeredCharactersProp; private void OnEnable() { wsPortProp = serializedObject.FindProperty("wsPort"); autoStartProp = serializedObject.FindProperty("autoStart"); registeredCharactersProp = serializedObject.FindProperty("registeredCharacters"); } public override void OnInspectorGUI() { serializedObject.Update(); RetargetingRemoteController controller = (RetargetingRemoteController)target; // 헤더 EditorGUILayout.Space(5); EditorGUILayout.LabelField("리타게팅 리모컨 (WebSocket)", EditorStyles.boldLabel); EditorGUILayout.Space(5); // 상태 표시 EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("상태:", GUILayout.Width(40)); if (Application.isPlaying) { if (controller.IsRunning) { GUI.color = Color.green; EditorGUILayout.LabelField("실행 중", EditorStyles.boldLabel); GUI.color = Color.white; } else { GUI.color = Color.yellow; EditorGUILayout.LabelField("중지됨", EditorStyles.boldLabel); GUI.color = Color.white; } } else { GUI.color = Color.gray; EditorGUILayout.LabelField("대기 중 (플레이 모드 필요)", EditorStyles.boldLabel); GUI.color = Color.white; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(10); // 서버 설정 EditorGUILayout.LabelField("서버 설정", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.PropertyField(wsPortProp, new GUIContent("WebSocket 포트")); EditorGUILayout.PropertyField(autoStartProp, new GUIContent("자동 시작")); EditorGUILayout.EndVertical(); EditorGUILayout.Space(5); EditorGUILayout.HelpBox("리타게팅 UI는 Streamingle Dashboard에 통합되었습니다.\n대시보드의 Retargeting 탭에서 사용하세요.", MessageType.Info); EditorGUILayout.Space(10); // 캐릭터 등록 EditorGUILayout.LabelField("등록된 캐릭터", EditorStyles.boldLabel); EditorGUILayout.PropertyField(registeredCharactersProp, GUIContent.none); // 자동 등록 버튼 EditorGUILayout.Space(5); if (GUILayout.Button("씬에서 캐릭터 자동 찾기")) { AutoFindCharacters(); } EditorGUILayout.Space(10); // 서버 제어 버튼 (플레이 모드에서만) if (Application.isPlaying) { EditorGUILayout.LabelField("서버 제어", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); if (controller.IsRunning) { if (GUILayout.Button("서버 중지", GUILayout.Height(30))) { controller.StopServer(); } } else { if (GUILayout.Button("서버 시작", GUILayout.Height(30))) { controller.StartServer(); } } EditorGUILayout.EndHorizontal(); } serializedObject.ApplyModifiedProperties(); } private void AutoFindCharacters() { var characters = FindObjectsByType(FindObjectsSortMode.None); registeredCharactersProp.ClearArray(); foreach (var character in characters) { int index = registeredCharactersProp.arraySize; registeredCharactersProp.InsertArrayElementAtIndex(index); registeredCharactersProp.GetArrayElementAtIndex(index).objectReferenceValue = character; } serializedObject.ApplyModifiedProperties(); Debug.Log($"[RetargetingRemote] {characters.Length}개의 캐릭터를 찾았습니다."); } } }