using UnityEngine; using UnityEditor; namespace Streamingle.Editor { public class StreamingleControllerSetupToolAdvanced : EditorWindow { private bool createCameraManager = true; private bool createItemController = true; private bool createEventController = true; private bool createStreamDeckManager = true; private bool createAvatarOutfitController = true; private bool createSystemController = true; private string parentObjectName = "Streamingle 컨트롤러들"; private bool createParentObject = true; // 고급 옵션 private bool autoConnectExistingControllers = true; private bool setupDefaultSettings = true; private bool createSampleData = false; private bool moveExistingControllersToParent = true; // 기존 컨트롤러 참조 private StreamDeckServerManager existingStreamDeckManager; private CameraManager existingCameraManager; private ItemController existingItemController; private EventController existingEventController; private AvatarOutfitController existingAvatarOutfitController; private SystemController existingSystemController; [MenuItem("Tools/Streamingle/고급 컨트롤러 설정 도구")] public static void ShowWindow() { GetWindow("고급 Streamingle 설정"); } private void OnEnable() { FindExistingControllers(); } private void OnGUI() { GUILayout.Label("고급 Streamingle 컨트롤러 설정 도구", EditorStyles.boldLabel); GUILayout.Space(10); // 기존 컨트롤러 상태 표시 ShowExistingControllersStatus(); GUILayout.Space(10); // 부모 오브젝트 설정 EditorGUILayout.BeginVertical("box"); GUILayout.Label("부모 오브젝트 설정", EditorStyles.boldLabel); createParentObject = EditorGUILayout.Toggle("부모 오브젝트 생성", createParentObject); if (createParentObject) { parentObjectName = EditorGUILayout.TextField("부모 오브젝트 이름", parentObjectName); } EditorGUILayout.EndVertical(); GUILayout.Space(10); // 컨트롤러 선택 EditorGUILayout.BeginVertical("box"); GUILayout.Label("생성할 컨트롤러들", EditorStyles.boldLabel); createStreamDeckManager = EditorGUILayout.Toggle("StreamDeck 서버 매니저", createStreamDeckManager); createSystemController = EditorGUILayout.Toggle("시스템 컨트롤러", createSystemController); createCameraManager = EditorGUILayout.Toggle("카메라 매니저", createCameraManager); createItemController = EditorGUILayout.Toggle("아이템 컨트롤러", createItemController); createEventController = EditorGUILayout.Toggle("이벤트 컨트롤러", createEventController); createAvatarOutfitController = EditorGUILayout.Toggle("아바타 의상 컨트롤러", createAvatarOutfitController); EditorGUILayout.EndVertical(); GUILayout.Space(10); // 고급 옵션 EditorGUILayout.BeginVertical("box"); GUILayout.Label("고급 옵션", EditorStyles.boldLabel); autoConnectExistingControllers = EditorGUILayout.Toggle("기존 컨트롤러 자동 연결", autoConnectExistingControllers); setupDefaultSettings = EditorGUILayout.Toggle("기본 설정 구성", setupDefaultSettings); createSampleData = EditorGUILayout.Toggle("샘플 데이터 생성", createSampleData); moveExistingControllersToParent = EditorGUILayout.Toggle("기존 컨트롤러를 부모 하위로 이동", moveExistingControllersToParent); EditorGUILayout.EndVertical(); GUILayout.Space(20); // 버튼들 EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("선택된 컨트롤러들 생성", GUILayout.Height(30))) { CreateControllers(); } if (GUILayout.Button("기존 컨트롤러들 연결", GUILayout.Height(30))) { ConnectExistingControllers(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("컨트롤러 상태 새로고침", GUILayout.Height(25))) { FindExistingControllers(); } if (GUILayout.Button("기존 컨트롤러들을 부모 하위로 이동", GUILayout.Height(25))) { MoveExistingControllersToParent(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); // 정보 표시 EditorGUILayout.HelpBox( "자동 감지 및 연결 기능이 포함된 고급 설정 도구입니다.\n" + "'기존 컨트롤러들 연결'을 사용하여 찾은 컨트롤러들을 StreamDeck 매니저에 연결하세요.\n" + "'기존 컨트롤러들을 부모 하위로 이동'을 사용하여 발견된 컨트롤러들을 정리하세요.", MessageType.Info ); } private void ShowExistingControllersStatus() { EditorGUILayout.BeginVertical("box"); GUILayout.Label("기존 컨트롤러 상태", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); GUILayout.Label("StreamDeck 서버 매니저:", GUILayout.Width(200)); if (existingStreamDeckManager != null) { string parentInfo = GetParentInfo(existingStreamDeckManager.transform); EditorGUILayout.LabelField($"✓ 발견됨 {parentInfo}", EditorStyles.boldLabel); } else { EditorGUILayout.LabelField("✗ 발견되지 않음", EditorStyles.boldLabel); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("카메라 매니저:", GUILayout.Width(200)); if (existingCameraManager != null) { string parentInfo = GetParentInfo(existingCameraManager.transform); EditorGUILayout.LabelField($"✓ 발견됨 {parentInfo}", EditorStyles.boldLabel); } else { EditorGUILayout.LabelField("✗ 발견되지 않음", EditorStyles.boldLabel); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("아이템 컨트롤러:", GUILayout.Width(200)); if (existingItemController != null) { string parentInfo = GetParentInfo(existingItemController.transform); EditorGUILayout.LabelField($"✓ 발견됨 {parentInfo}", EditorStyles.boldLabel); } else { EditorGUILayout.LabelField("✗ 발견되지 않음", EditorStyles.boldLabel); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("이벤트 컨트롤러:", GUILayout.Width(200)); if (existingEventController != null) { string parentInfo = GetParentInfo(existingEventController.transform); EditorGUILayout.LabelField($"✓ 발견됨 {parentInfo}", EditorStyles.boldLabel); } else { EditorGUILayout.LabelField("✗ 발견되지 않음", EditorStyles.boldLabel); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("아바타 의상 컨트롤러:", GUILayout.Width(200)); if (existingAvatarOutfitController != null) { string parentInfo = GetParentInfo(existingAvatarOutfitController.transform); EditorGUILayout.LabelField($"✓ 발견됨 {parentInfo}", EditorStyles.boldLabel); } else { EditorGUILayout.LabelField("✗ 발견되지 않음", EditorStyles.boldLabel); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("시스템 컨트롤러:", GUILayout.Width(200)); if (existingSystemController != null) { string parentInfo = GetParentInfo(existingSystemController.transform); EditorGUILayout.LabelField($"✓ 발견됨 {parentInfo}", EditorStyles.boldLabel); } else { EditorGUILayout.LabelField("✗ 발견되지 않음", EditorStyles.boldLabel); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } private string GetParentInfo(Transform transform) { if (transform.parent == null) { return "(루트)"; } else { return $"({transform.parent.name} 하위)"; } } private void FindExistingControllers() { existingStreamDeckManager = FindObjectOfType(); existingCameraManager = FindObjectOfType(); existingItemController = FindObjectOfType(); existingEventController = FindObjectOfType(); existingAvatarOutfitController = FindObjectOfType(); existingSystemController = FindObjectOfType(); } private void CreateControllers() { GameObject parentObject = null; // 부모 오브젝트 생성 if (createParentObject) { parentObject = new GameObject(parentObjectName); UnityEngine.Debug.Log($"부모 오브젝트 생성됨: {parentObjectName}"); } // StreamDeck Server Manager 생성 if (createStreamDeckManager && existingStreamDeckManager == null) { CreateStreamDeckManager(parentObject); } // System Controller 생성 if (createSystemController && existingSystemController == null) { CreateSystemController(parentObject); } // Camera Manager 생성 if (createCameraManager && existingCameraManager == null) { CreateCameraManager(parentObject); } // Item Controller 생성 if (createItemController && existingItemController == null) { CreateItemController(parentObject); } // Event Controller 생성 if (createEventController && existingEventController == null) { CreateEventController(parentObject); } // Avatar Outfit Controller 생성 if (createAvatarOutfitController && existingAvatarOutfitController == null) { CreateAvatarOutfitController(parentObject); } // 기존 컨트롤러들을 부모 하위로 이동 if (moveExistingControllersToParent && parentObject != null) { MoveExistingControllersToParent(parentObject); } // 생성된 오브젝트들을 선택 if (parentObject != null) { Selection.activeGameObject = parentObject; EditorGUIUtility.PingObject(parentObject); } // 기존 컨트롤러 상태 업데이트 FindExistingControllers(); UnityEngine.Debug.Log("Streamingle 컨트롤러 설정 완료!"); } private void MoveExistingControllersToParent(GameObject parent = null) { if (parent == null) { // 기존 부모 오브젝트 찾기 또는 생성 parent = GameObject.Find(parentObjectName); if (parent == null) { parent = new GameObject(parentObjectName); UnityEngine.Debug.Log($"부모 오브젝트 생성됨: {parentObjectName}"); } } int movedCount = 0; // StreamDeck Server Manager 이동 if (existingStreamDeckManager != null && existingStreamDeckManager.transform.parent != parent.transform) { existingStreamDeckManager.transform.SetParent(parent.transform); movedCount++; UnityEngine.Debug.Log($"StreamDeck 서버 매니저를 {parent.name} 하위로 이동"); } // Camera Manager 이동 if (existingCameraManager != null && existingCameraManager.transform.parent != parent.transform) { existingCameraManager.transform.SetParent(parent.transform); movedCount++; UnityEngine.Debug.Log($"카메라 매니저를 {parent.name} 하위로 이동"); } // Item Controller 이동 if (existingItemController != null && existingItemController.transform.parent != parent.transform) { existingItemController.transform.SetParent(parent.transform); movedCount++; UnityEngine.Debug.Log($"아이템 컨트롤러를 {parent.name} 하위로 이동"); } // Event Controller 이동 if (existingEventController != null && existingEventController.transform.parent != parent.transform) { existingEventController.transform.SetParent(parent.transform); movedCount++; UnityEngine.Debug.Log($"이벤트 컨트롤러를 {parent.name} 하위로 이동"); } // Avatar Outfit Controller 이동 if (existingAvatarOutfitController != null && existingAvatarOutfitController.transform.parent != parent.transform) { existingAvatarOutfitController.transform.SetParent(parent.transform); movedCount++; UnityEngine.Debug.Log($"아바타 의상 컨트롤러를 {parent.name} 하위로 이동"); } // System Controller 이동 if (existingSystemController != null && existingSystemController.transform.parent != parent.transform) { existingSystemController.transform.SetParent(parent.transform); movedCount++; UnityEngine.Debug.Log($"시스템 컨트롤러를 {parent.name} 하위로 이동"); } if (movedCount > 0) { UnityEngine.Debug.Log($"{movedCount}개의 컨트롤러를 {parent.name} 하위로 이동했습니다."); // 부모 오브젝트 선택 Selection.activeGameObject = parent; EditorGUIUtility.PingObject(parent); } else { UnityEngine.Debug.Log("이동할 컨트롤러가 없습니다."); } } private void ConnectExistingControllers() { if (existingStreamDeckManager == null) { UnityEngine.Debug.LogError("StreamDeck 서버 매니저를 찾을 수 없습니다! 먼저 생성해주세요."); return; } // StreamDeck Manager에 컨트롤러들 연결 SerializedObject serializedObject = new SerializedObject(existingStreamDeckManager); serializedObject.Update(); // Camera Manager 연결 if (existingCameraManager != null) { var cameraManagerProperty = serializedObject.FindProperty("cameraManager"); if (cameraManagerProperty != null) { cameraManagerProperty.objectReferenceValue = existingCameraManager; } } // Item Controller 연결 if (existingItemController != null) { var itemControllerProperty = serializedObject.FindProperty("itemController"); if (itemControllerProperty != null) { itemControllerProperty.objectReferenceValue = existingItemController; } } // Event Controller 연결 if (existingEventController != null) { var eventControllerProperty = serializedObject.FindProperty("eventController"); if (eventControllerProperty != null) { eventControllerProperty.objectReferenceValue = existingEventController; } } // Avatar Outfit Controller 연결 if (existingAvatarOutfitController != null) { var avatarOutfitControllerProperty = serializedObject.FindProperty("avatarOutfitController"); if (avatarOutfitControllerProperty != null) { avatarOutfitControllerProperty.objectReferenceValue = existingAvatarOutfitController; } } // System Controller 연결 if (existingSystemController != null) { var systemControllerProperty = serializedObject.FindProperty("systemController"); if (systemControllerProperty != null) { systemControllerProperty.objectReferenceValue = existingSystemController; } } serializedObject.ApplyModifiedProperties(); UnityEngine.Debug.Log("기존 컨트롤러들을 StreamDeck 서버 매니저에 연결했습니다!"); } private void CreateStreamDeckManager(GameObject parent) { GameObject streamDeckObject = new GameObject("StreamDeck 서버 매니저"); if (parent != null) { streamDeckObject.transform.SetParent(parent.transform); } // StreamDeckServerManager 스크립트 추가 var streamDeckManager = streamDeckObject.AddComponent(); // 기본 설정 SerializedObject serializedObject = new SerializedObject(streamDeckManager); serializedObject.Update(); // 포트 설정 (기본값: 10701) var portProperty = serializedObject.FindProperty("port"); if (portProperty != null) { portProperty.intValue = 10701; } serializedObject.ApplyModifiedProperties(); UnityEngine.Debug.Log("StreamDeck 서버 매니저 생성됨"); } private void CreateCameraManager(GameObject parent) { GameObject cameraObject = new GameObject("카메라 매니저"); if (parent != null) { cameraObject.transform.SetParent(parent.transform); } // CameraManager 스크립트 추가 var cameraManager = cameraObject.AddComponent(); // 기본 설정 SerializedObject serializedObject = new SerializedObject(cameraManager); serializedObject.Update(); // 카메라 프리셋 리스트 초기화 var cameraPresetsProperty = serializedObject.FindProperty("cameraPresets"); if (cameraPresetsProperty != null) { cameraPresetsProperty.ClearArray(); cameraPresetsProperty.arraySize = 0; } serializedObject.ApplyModifiedProperties(); UnityEngine.Debug.Log("카메라 매니저 생성됨"); } private void CreateItemController(GameObject parent) { GameObject itemObject = new GameObject("아이템 컨트롤러"); if (parent != null) { itemObject.transform.SetParent(parent.transform); } // ItemController 스크립트 추가 var itemController = itemObject.AddComponent(); // 기본 설정 SerializedObject serializedObject = new SerializedObject(itemController); serializedObject.Update(); // 아이템 그룹 리스트 초기화 var itemGroupsProperty = serializedObject.FindProperty("itemGroups"); if (itemGroupsProperty != null) { itemGroupsProperty.ClearArray(); itemGroupsProperty.arraySize = 0; } serializedObject.ApplyModifiedProperties(); UnityEngine.Debug.Log("아이템 컨트롤러 생성됨"); } private void CreateEventController(GameObject parent) { GameObject eventObject = new GameObject("이벤트 컨트롤러"); if (parent != null) { eventObject.transform.SetParent(parent.transform); } // EventController 스크립트 추가 var eventController = eventObject.AddComponent(); // 기본 설정 SerializedObject serializedObject = new SerializedObject(eventController); serializedObject.Update(); // 이벤트 그룹 리스트 초기화 var eventGroupsProperty = serializedObject.FindProperty("eventGroups"); if (eventGroupsProperty != null) { eventGroupsProperty.ClearArray(); eventGroupsProperty.arraySize = 0; } // 자동 찾기 비활성화 var autoFindEventsProperty = serializedObject.FindProperty("autoFindEvents"); if (autoFindEventsProperty != null) { autoFindEventsProperty.boolValue = false; } serializedObject.ApplyModifiedProperties(); UnityEngine.Debug.Log("이벤트 컨트롤러 생성됨"); } private void CreateAvatarOutfitController(GameObject parent) { GameObject avatarOutfitObject = new GameObject("아바타 의상 컨트롤러"); if (parent != null) { avatarOutfitObject.transform.SetParent(parent.transform); } // AvatarOutfitController 스크립트 추가 var avatarOutfitController = avatarOutfitObject.AddComponent(); // 기본 설정 SerializedObject serializedObject = new SerializedObject(avatarOutfitController); serializedObject.Update(); // 아바타 리스트 초기화 var avatarsProperty = serializedObject.FindProperty("avatars"); if (avatarsProperty != null) { avatarsProperty.ClearArray(); avatarsProperty.arraySize = 0; } // 자동 찾기 비활성화 var autoFindAvatarsProperty = serializedObject.FindProperty("autoFindAvatars"); if (autoFindAvatarsProperty != null) { autoFindAvatarsProperty.boolValue = false; } serializedObject.ApplyModifiedProperties(); UnityEngine.Debug.Log("아바타 의상 컨트롤러 생성됨"); } private void CreateSystemController(GameObject parent) { GameObject systemControllerObject = new GameObject("시스템 컨트롤러"); if (parent != null) { systemControllerObject.transform.SetParent(parent.transform); } // SystemController 스크립트 추가 var systemController = systemControllerObject.AddComponent(); // 기본 설정 SerializedObject serializedObject = new SerializedObject(systemController); serializedObject.Update(); // OptiTrack 클라이언트 자동 찾기는 Start()에서 수행됨 // Motion Recorder 자동 찾기 활성화 var autoFindRecordersProperty = serializedObject.FindProperty("autoFindRecorders"); if (autoFindRecordersProperty != null) { autoFindRecordersProperty.boolValue = true; } // Facial Motion 클라이언트 자동 찾기 활성화 var autoFindFacialMotionClientsProperty = serializedObject.FindProperty("autoFindFacialMotionClients"); if (autoFindFacialMotionClientsProperty != null) { autoFindFacialMotionClientsProperty.boolValue = true; } // 디버그 로그 활성화 var enableDebugLogProperty = serializedObject.FindProperty("enableDebugLog"); if (enableDebugLogProperty != null) { enableDebugLogProperty.boolValue = true; } serializedObject.ApplyModifiedProperties(); UnityEngine.Debug.Log("시스템 컨트롤러 생성됨"); } } }