console.log('๐Ÿ‘— Avatar Outfit Property Inspector ๋กœ๋“œ๋จ'); // ํ™”๋ฉด์— ๋กœ๊ทธ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ํ•จ์ˆ˜ function logToScreen(msg, color = "#00ff00") { let logDiv = document.getElementById('logArea'); if (!logDiv) { return; // ๋กœ๊ทธ ์˜์—ญ์ด ์•„์ง ์—†์œผ๋ฉด ๋ฌด์‹œ } const line = document.createElement('div'); line.style.color = color; line.textContent = `[${new Date().toLocaleTimeString()}] ${msg}`; logDiv.appendChild(line); logDiv.scrollTop = logDiv.scrollHeight; // ๋กœ๊ทธ๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์•„์ง€๋ฉด ์˜ค๋ž˜๋œ ๊ฒƒ ์ œ๊ฑฐ (์ตœ๋Œ€ 100์ค„) if (logDiv.children.length > 100) { logDiv.removeChild(logDiv.firstChild); } } // ๊ธฐ์กด console.log/console.error๋ฅผ ํ™”๋ฉด์—๋„ ์ถœ๋ ฅ const origLog = console.log; console.log = function(...args) { origLog.apply(console, args); const msg = args.map(a => (typeof a === 'object' ? JSON.stringify(a, null, 2) : a)).join(' '); logToScreen(msg, '#00ff00'); }; const origError = console.error; console.error = function(...args) { origError.apply(console, args); const msg = args.map(a => (typeof a === 'object' ? JSON.stringify(a, null, 2) : a)).join(' '); logToScreen(msg, '#ff5555'); }; const origWarn = console.warn; console.warn = function(...args) { origWarn.apply(console, args); const msg = args.map(a => (typeof a === 'object' ? JSON.stringify(a, null, 2) : a)).join(' '); logToScreen(msg, '#ffaa00'); }; // ์ „์—ญ ๋ณ€์ˆ˜ let websocket = null; let uuid = null; // Property Inspector UUID let actionContext = null; // ๋ฒ„ํŠผ๋ณ„ ๊ณ ์œ  ์ปจํ…์ŠคํŠธ let actionInfo = null; let avatarList = []; let isUnityConnected = false; let settings = {}; // Stream Deck ์—ฐ๊ฒฐ function connectElgatoStreamDeckSocket(inPort, inPropertyInspectorUUID, inRegisterEvent, inInfo, inActionInfo) { console.log('๐Ÿ”Œ Avatar Outfit Property Inspector ์—ฐ๊ฒฐ ์ค‘...'); console.log('๐Ÿ“ก ํฌํŠธ:', inPort, 'UUID:', inPropertyInspectorUUID); uuid = inPropertyInspectorUUID; // Parse action info - ๋ฒ„ํŠผ๋ณ„ ๊ณ ์œ  ์ปจํ…์ŠคํŠธ์™€ ์„ค์ • ์ถ”์ถœ try { if (inActionInfo) { console.log('๐Ÿ” Raw actionInfo:', inActionInfo); actionInfo = JSON.parse(inActionInfo); actionContext = actionInfo.context; // ๋ฒ„ํŠผ๋ณ„ ๊ณ ์œ  ์ปจํ…์ŠคํŠธ settings = actionInfo.payload?.settings || {}; // actionType์ด ์—†์œผ๋ฉด ๊ฐ•์ œ๋กœ ์„ค์ • if (!settings.actionType) { settings.actionType = 'avatar_outfit'; console.log('๐Ÿ”ง actionType์ด ์—†์–ด์„œ ๊ฐ•์ œ๋กœ ์„ค์ •:', settings.actionType); } console.log('โš™๏ธ Property Inspector UUID:', uuid); console.log('โš™๏ธ ๋ฒ„ํŠผ ์ปจํ…์ŠคํŠธ:', actionContext); console.log('โš™๏ธ ์ดˆ๊ธฐ ์„ค์ •:', settings); console.log('โš™๏ธ actionInfo ์ „์ฒด:', actionInfo); } else { console.error('โŒ actionInfo๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค!'); } } catch (error) { console.error('โŒ ActionInfo ํŒŒ์‹ฑ ์˜ค๋ฅ˜:', error); console.log('๐Ÿ” ํŒŒ์‹ฑ ์‹œ๋„ํ•œ ๋ฌธ์ž์—ด:', inActionInfo); } websocket = new WebSocket('ws://localhost:' + inPort); websocket.onopen = function() { console.log('โœ… Property Inspector ์—ฐ๊ฒฐ๋จ'); // StreamDeck์— ๋“ฑ๋ก (์นด๋ฉ”๋ผ์™€ ๋™์ผํ•œ ํŒจํ„ด) websocket.send(JSON.stringify({ event: inRegisterEvent, uuid: inPropertyInspectorUUID })); // Unity ์ƒํƒœ ์š”์ฒญ (์นด๋ฉ”๋ผ์™€ ๋™์ผํ•œ ํŒจํ„ด) setTimeout(() => { console.log('๐Ÿ” Plugin์— ๋””๋ฒ„๊ทธ ๋ฉ”์‹œ์ง€ ์ „์†ก ์‹œ์ž‘'); // actionType์ด ์„ค์ •๋˜์—ˆ์œผ๋ฉด ์ฆ‰์‹œ Plugin์— ์ €์žฅ if (settings.actionType === 'avatar_outfit') { const actionTypeMessage = { action: 'com.mirabox.streamingle.avatar_outfit', event: 'setSettings', context: uuid, payload: settings }; websocket.send(JSON.stringify(actionTypeMessage)); console.log('๐Ÿ”ง ์ดˆ๊ธฐ actionType ์„ค์ •์„ Plugin์— ์ €์žฅ:', settings); } // ๋จผ์ € Plugin์ด ์ด ๋ฒ„ํŠผ์„ ์ธ์‹ํ•˜๋Š”์ง€ ํ™•์ธ sendToPlugin('debug_test', { message: 'Avatar outfit controller test', context: actionContext, action: 'com.mirabox.streamingle.avatar_outfit' }); // Unity ์ƒํƒœ ์š”์ฒญ sendToPlugin('get_unity_status'); }, 500); // ์ดˆ๊ธฐ ์„ค์ • ๋กœ๋“œ loadInitialSettings(); }; websocket.onmessage = function(evt) { try { const jsonObj = JSON.parse(evt.data); handleMessage(jsonObj); } catch (error) { console.error('โŒ ๋ฉ”์‹œ์ง€ ํŒŒ์‹ฑ ์˜ค๋ฅ˜:', error); } }; websocket.onclose = function() { console.log('โŒ Property Inspector ์—ฐ๊ฒฐ ๋Š์–ด์ง'); websocket = null; // ์—ฐ๊ฒฐ ์ƒํƒœ๋ฅผ ๋น„์—ฐ๊ฒฐ๋กœ ํ‘œ์‹œ handleUnityConnected(false); }; websocket.onerror = function(error) { console.error('โŒ Property Inspector ์—ฐ๊ฒฐ ์˜ค๋ฅ˜:', error); websocket = null; // ์—ฐ๊ฒฐ ์ƒํƒœ๋ฅผ ๋น„์—ฐ๊ฒฐ๋กœ ํ‘œ์‹œ handleUnityConnected(false); }; } // ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ function handleMessage(jsonObj) { console.log('๐Ÿ“จ ๋ฉ”์‹œ์ง€ ์ˆ˜์‹ :', jsonObj.event); console.log('๐Ÿ“จ ์ „์ฒด ๋ฉ”์‹œ์ง€:', JSON.stringify(jsonObj, null, 2)); // sendToPropertyInspector ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ (์นด๋ฉ”๋ผ ๋ฐฉ์‹๊ณผ ๋™์ผ) if (jsonObj.event === 'sendToPropertyInspector' && jsonObj.payload && jsonObj.payload.event) { const innerEvent = jsonObj.payload.event; console.log('๐Ÿ“จ ๋‚ด๋ถ€ ์ด๋ฒคํŠธ:', innerEvent, 'payload:', jsonObj.payload); switch (innerEvent) { case 'unity_connected': console.log('โœ… Unity ์—ฐ๊ฒฐ ์ƒํƒœ ์—…๋ฐ์ดํŠธ'); handleUnityConnected(jsonObj.payload.connected); break; case 'avatar_outfit_list': console.log('๐Ÿ‘— ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ชฉ๋ก ์ˆ˜์‹ '); handleAvatarOutfitList(jsonObj.payload); break; case 'avatar_outfit_changed': console.log('๐ŸŽญ ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ณ€๊ฒฝ ์•Œ๋ฆผ'); handleAvatarOutfitChanged(jsonObj.payload); break; case 'camera_list': console.log('โš ๏ธ ์นด๋ฉ”๋ผ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•˜์ง€๋งŒ ์•„๋ฐ”ํƒ€ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ๋Š” ๋ฌด์‹œํ•จ'); break; case 'item_list': console.log('โš ๏ธ ์•„์ดํ…œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•˜์ง€๋งŒ ์•„๋ฐ”ํƒ€ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ๋Š” ๋ฌด์‹œํ•จ'); break; case 'event_list': console.log('โš ๏ธ ์ด๋ฒคํŠธ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•˜์ง€๋งŒ ์•„๋ฐ”ํƒ€ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ๋Š” ๋ฌด์‹œํ•จ'); break; case 'debug_response': console.log('โœ… Plugin์œผ๋กœ๋ถ€ํ„ฐ ๋””๋ฒ„๊ทธ ์‘๋‹ต ๋ฐ›์Œ!'); console.log('๐Ÿ“จ ์‘๋‹ต ๋ฐ์ดํ„ฐ:', jsonObj.payload); break; default: console.log('โ“ ์•Œ ์ˆ˜ ์—†๋Š” ๋‚ด๋ถ€ ์ด๋ฒคํŠธ:', innerEvent); break; } return; } switch(jsonObj.event) { case 'sendToPropertyInspector': if (jsonObj.payload) { handlePluginMessage(jsonObj.payload); } break; case 'didReceiveSettings': if (jsonObj.payload && jsonObj.payload.settings) { updateUIFromSettings(jsonObj.payload.settings); } break; // ๊ธฐ์กด ๋ฐฉ์‹๋„ ์œ ์ง€ (ํ˜ธํ™˜์„ฑ) case 'unity_connected': console.log('โœ… Unity ์—ฐ๊ฒฐ ์ƒํƒœ ์—…๋ฐ์ดํŠธ (๊ธฐ์กด ๋ฐฉ์‹)'); handleUnityConnected(jsonObj.payload?.connected); break; case 'avatar_outfit_list': console.log('๐Ÿ‘— ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ชฉ๋ก ์ˆ˜์‹  (๊ธฐ์กด ๋ฐฉ์‹)'); handleAvatarOutfitList(jsonObj.payload); break; case 'avatar_outfit_changed': console.log('๐ŸŽญ ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ณ€๊ฒฝ ์•Œ๋ฆผ (๊ธฐ์กด ๋ฐฉ์‹)'); handleAvatarOutfitChanged(jsonObj.payload); break; } } // ํ”Œ๋Ÿฌ๊ทธ์ธ ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ function handlePluginMessage(payload) { console.log('๐Ÿ“จ ํ”Œ๋Ÿฌ๊ทธ์ธ ๋ฉ”์‹œ์ง€:', payload.event, payload); switch(payload.event) { case 'unity_connected': console.log('๐Ÿ”— Unity ์—ฐ๊ฒฐ ์ด๋ฒคํŠธ ์ˆ˜์‹ :', payload); handleUnityConnected(payload.connected); break; case 'avatar_outfit_list': console.log('๐Ÿ‘— ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ชฉ๋ก ์ด๋ฒคํŠธ ์ˆ˜์‹ :', payload); handleAvatarOutfitList(payload); break; case 'avatar_outfit_changed': console.log('๐ŸŽญ ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ณ€๊ฒฝ ์ด๋ฒคํŠธ ์ˆ˜์‹ :', payload); handleAvatarOutfitChanged(payload); break; default: console.log('โ“ ์•Œ ์ˆ˜ ์—†๋Š” ์ด๋ฒคํŠธ:', payload.event); break; } } // Unity ์—ฐ๊ฒฐ ์ƒํƒœ ์ฒ˜๋ฆฌ function handleUnityConnected(connected) { console.log('๐Ÿ”— Unity ์—ฐ๊ฒฐ ์ƒํƒœ:', connected); isUnityConnected = connected; const statusIndicator = document.getElementById('connection-status'); const statusDot = document.getElementById('status-dot'); const statusText = document.getElementById('status-text'); const connectionDetail = document.getElementById('connection-detail'); const avatarSelect = document.getElementById('avatar-select'); const refreshButton = document.getElementById('refresh-button'); if (connected) { statusIndicator.classList.add('connected'); statusDot.classList.add('connected'); statusText.textContent = 'Unity ์„œ๋ฒ„ ์—ฐ๊ฒฐ๋จ'; connectionDetail.textContent = '์•„๋ฐ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘...'; avatarSelect.disabled = false; refreshButton.disabled = false; avatarSelect.innerHTML = ''; // ์—ฐ๊ฒฐ ์ฆ‰์‹œ ์•„๋ฐ”ํƒ€ ๋ชฉ๋ก ์š”์ฒญ console.log('๐Ÿ”„ Unity ์—ฐ๊ฒฐ๋จ - ์•„๋ฐ”ํƒ€ ๋ชฉ๋ก ์š”์ฒญ'); setTimeout(() => { refreshAvatarList(); }, 500); } else { statusIndicator.classList.remove('connected'); statusDot.classList.remove('connected'); statusText.textContent = 'Unity ์„œ๋ฒ„ ์—ฐ๊ฒฐ ์•ˆ๋จ'; connectionDetail.textContent = 'Unity๋ฅผ ์‹คํ–‰ํ•˜๊ณ  AvatarOutfitController๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”'; avatarSelect.disabled = true; refreshButton.disabled = true; avatarSelect.innerHTML = ''; updateOutfitSelect(-1); } } // ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ชฉ๋ก ์ฒ˜๋ฆฌ function handleAvatarOutfitList(payload) { console.log('๐Ÿ‘— ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ชฉ๋ก ์ˆ˜์‹ :', payload); console.log('๐Ÿ‘— payload.avatars:', payload.avatars); console.log('๐Ÿ‘— Array.isArray(payload.avatars):', Array.isArray(payload.avatars)); if (payload.avatars && Array.isArray(payload.avatars)) { avatarList = payload.avatars; console.log('๐Ÿ‘— ์•„๋ฐ”ํƒ€ ๋ชฉ๋ก ์ €์žฅ๋จ:', avatarList.length, '๊ฐœ'); console.log('๐Ÿ‘— ์•„๋ฐ”ํƒ€ ๋ชฉ๋ก ์ƒ์„ธ:', avatarList); updateAvatarSelect(); // ํ˜„์žฌ ์„ค์ •๋œ ์•„๋ฐ”ํƒ€ ํ™•์ธ const avatarSelect = document.getElementById('avatar-select'); if (avatarSelect.value !== '') { const selectedIndex = parseInt(avatarSelect.value); if (!isNaN(selectedIndex)) { updateOutfitSelect(selectedIndex); } } } else { console.log('โŒ ์•„๋ฐ”ํƒ€ ๋ฐ์ดํ„ฐ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Œ:', payload.avatars); avatarList = []; updateAvatarSelect(); } updateCurrentStatus(payload.currentIndex); } // ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ณ€๊ฒฝ ์ฒ˜๋ฆฌ function handleAvatarOutfitChanged(payload) { console.log('๐ŸŽญ ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ณ€๊ฒฝ:', payload); handleAvatarOutfitList(payload); // ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์ฒ˜๋ฆฌ } // ์•„๋ฐ”ํƒ€ ์„ ํƒ ์—…๋ฐ์ดํŠธ function updateAvatarSelect() { const avatarSelect = document.getElementById('avatar-select'); const connectionDetail = document.getElementById('connection-detail'); avatarSelect.innerHTML = ''; if (avatarList.length === 0) { avatarSelect.innerHTML = ''; connectionDetail.textContent = 'Unity์—์„œ AvatarOutfitController์— ์•„๋ฐ”ํƒ€๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”'; return; } avatarSelect.innerHTML = ''; avatarList.forEach((avatar, index) => { const option = document.createElement('option'); option.value = index; option.textContent = `${avatar.name} (${avatar.outfits ? avatar.outfits.length : 0}๊ฐœ ์˜์ƒ)`; avatarSelect.appendChild(option); }); connectionDetail.textContent = `${avatarList.length}๊ฐœ์˜ ์•„๋ฐ”ํƒ€๋ฅผ ๋ฐœ๊ฒฌํ–ˆ์Šต๋‹ˆ๋‹ค`; } // ์˜์ƒ ์„ ํƒ ์—…๋ฐ์ดํŠธ function updateOutfitSelect(avatarIndex) { const outfitSelect = document.getElementById('outfit-select'); outfitSelect.innerHTML = ''; if (avatarIndex < 0 || avatarIndex >= avatarList.length) { outfitSelect.innerHTML = ''; outfitSelect.disabled = true; return; } const avatar = avatarList[avatarIndex]; if (!avatar.outfits || avatar.outfits.length === 0) { outfitSelect.innerHTML = ''; outfitSelect.disabled = true; return; } // ๊ธฐ๋ณธ ์„ ํƒ ์˜ต์…˜ ์ถ”๊ฐ€ outfitSelect.innerHTML = ''; // ์˜์ƒ ๋ชฉ๋ก ์ถ”๊ฐ€ avatar.outfits.forEach((outfit, index) => { const option = document.createElement('option'); option.value = index; option.textContent = outfit.name; outfitSelect.appendChild(option); }); outfitSelect.disabled = false; // ๊ธฐ๋ณธ๊ฐ’ ์„ค์ • (์ฒซ ๋ฒˆ์งธ ์˜์ƒ) if (avatar.outfits.length > 0) { outfitSelect.value = 0; } } // ํ˜„์žฌ ์ƒํƒœ ์—…๋ฐ์ดํŠธ function updateCurrentStatus(currentAvatarIndex) { const currentAvatar = document.getElementById('current-avatar'); const currentOutfit = document.getElementById('current-outfit'); if (currentAvatarIndex >= 0 && currentAvatarIndex < avatarList.length) { const avatar = avatarList[currentAvatarIndex]; currentAvatar.textContent = `ํ˜„์žฌ: ${avatar.name}`; currentOutfit.textContent = `ํ˜„์žฌ ์˜์ƒ: ${avatar.current_outfit_name || '์ •๋ณด ์—†์Œ'}`; } else { currentAvatar.textContent = 'ํ˜„์žฌ: ์„ ํƒ๋˜์ง€ ์•Š์Œ'; currentOutfit.textContent = 'ํ˜„์žฌ ์˜์ƒ: ์ •๋ณด ์—†์Œ'; } } // Send message to plugin function sendToPlugin(command, data = {}) { console.log('๐Ÿš€ sendToPlugin ํ˜ธ์ถœ:', command, data); console.log('๐Ÿ” WebSocket ์ƒํƒœ:', websocket ? 'available' : 'null'); console.log('๐Ÿ” actionContext ์ƒํƒœ:', actionContext); if (!websocket) { console.error('โŒ WebSocket not available'); return; } if (!uuid) { console.error('โŒ UUID not available'); return; } try { const message = { action: 'com.mirabox.streamingle.avatar_outfit', // manifest.json์˜ Action UUID event: 'sendToPlugin', context: uuid, // Property Inspector UUID (Stream Deck ํ‘œ์ค€) payload: { command, buttonContext: actionContext, // ๋ฒ„ํŠผ์˜ ์‹ค์ œ context ์ •๋ณด๋„ ํ•จ๊ป˜ ์ „์†ก ...data } }; websocket.send(JSON.stringify(message)); console.log('๐Ÿ“ค Message sent to plugin:', command, data, 'context:', uuid); } catch (error) { console.error('โŒ Failed to send message to plugin:', error); } } // Unity ์ƒํƒœ ์š”์ฒญ function requestUnityStatus() { sendToPlugin('get_unity_status'); } // ์•„๋ฐ”ํƒ€ ๋ชฉ๋ก ์ƒˆ๋กœ๊ณ ์นจ function refreshAvatarList() { sendToPlugin('refresh_avatar_outfit_list'); } // ์„ค์ • ์ €์žฅ function saveSettings() { if (!uuid) { console.error('โŒ No uuid available for saving settings'); return; } if (!websocket) { console.log('โš ๏ธ WebSocket์ด ์—ฐ๊ฒฐ๋˜์ง€ ์•Š์Œ, ์„ค์ • ์ €์žฅ ๊ฑด๋„ˆ๋œ€'); return; } const avatarSelect = document.getElementById('avatar-select'); const outfitSelect = document.getElementById('outfit-select'); const newSettings = { avatarIndex: parseInt(avatarSelect.value || '0'), outfitIndex: parseInt(outfitSelect.value || '0'), actionType: 'avatar_outfit' // ๐Ÿ”ฅ ์ค‘์š”: actionType ์ถ”๊ฐ€! }; // ์ „์—ญ ์„ค์ •๋„ ์—…๋ฐ์ดํŠธ settings = { ...settings, ...newSettings }; const message = { action: 'com.mirabox.streamingle.avatar_outfit', event: 'setSettings', context: uuid, // Property Inspector UUID ์‚ฌ์šฉ (Stream Deck ํ‘œ์ค€) payload: newSettings }; try { websocket.send(JSON.stringify(message)); console.log('๐Ÿ“ค ์„ค์ • ์ €์žฅ๋จ - Context:', uuid, 'Settings:', newSettings); // ์„ค์ •์ด ์ €์žฅ๋˜๋ฉด Plugin์—๊ฒŒ ์•„๋ฐ”ํƒ€ ์˜์ƒ ๋ณ€๊ฒฝ ์š”์ฒญ๋„ ๋ณด๋ƒ„ sendToPlugin('set_avatar_outfit', { avatarIndex: newSettings.avatarIndex, outfitIndex: newSettings.outfitIndex }); // ๋ฒ„ํŠผ ์ œ๋ชฉ ์—…๋ฐ์ดํŠธ ์š”์ฒญ sendToPlugin('update_title', { avatarIndex: newSettings.avatarIndex, outfitIndex: newSettings.outfitIndex }); } catch (error) { console.error('โŒ ์„ค์ • ์ €์žฅ ์‹คํŒจ:', error); websocket = null; handleUnityConnected(false); } } // ์ดˆ๊ธฐ ์„ค์ • ๋กœ๋“œ function loadInitialSettings() { console.log('๐Ÿ”ง ์ดˆ๊ธฐ ์„ค์ • ๋กœ๋“œ ์‹œ์ž‘'); console.log('๐Ÿ”ง ํ˜„์žฌ settings:', settings); // ์ดˆ๊ธฐํ™”๊ฐ€ ์™„๋ฃŒ๋œ ํ›„ UI ์—…๋ฐ์ดํŠธ setTimeout(() => { updateUIFromSettings(settings); }, 100); } // ์„ค์ •์—์„œ UI ์—…๋ฐ์ดํŠธ function updateUIFromSettings(settingsToApply) { console.log('๐ŸŽจ UI ์—…๋ฐ์ดํŠธ ์‹œ์ž‘:', settingsToApply); const avatarSelect = document.getElementById('avatar-select'); const outfitSelect = document.getElementById('outfit-select'); if (settingsToApply.avatarIndex !== undefined && avatarSelect) { console.log('๐Ÿ‘ค ์•„๋ฐ”ํƒ€ ์ธ๋ฑ์Šค ์ ์šฉ:', settingsToApply.avatarIndex); avatarSelect.value = settingsToApply.avatarIndex; updateOutfitSelect(settingsToApply.avatarIndex); } if (settingsToApply.outfitIndex !== undefined && outfitSelect) { console.log('๐Ÿ‘— ์˜์ƒ ์ธ๋ฑ์Šค ์ ์šฉ:', settingsToApply.outfitIndex); outfitSelect.value = settingsToApply.outfitIndex; } console.log('โœ… UI ์—…๋ฐ์ดํŠธ ์™„๋ฃŒ'); } // ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ document.addEventListener('DOMContentLoaded', function() { console.log('๐Ÿ‘— Avatar Outfit Property Inspector DOM ์ค€๋น„๋จ'); // ์•„๋ฐ”ํƒ€ ์„ ํƒ ๋ณ€๊ฒฝ const avatarSelect = document.getElementById('avatar-select'); if (avatarSelect) { avatarSelect.addEventListener('change', function() { const selectedIndex = parseInt(this.value); if (!isNaN(selectedIndex)) { updateOutfitSelect(selectedIndex); } else { updateOutfitSelect(-1); } saveSettings(); }); } // ์˜์ƒ ์„ ํƒ ๋ณ€๊ฒฝ const outfitSelect = document.getElementById('outfit-select'); if (outfitSelect) { outfitSelect.addEventListener('change', saveSettings); } // ์ƒˆ๋กœ๊ณ ์นจ ๋ฒ„ํŠผ const refreshButton = document.getElementById('refresh-button'); if (refreshButton) { refreshButton.addEventListener('click', function() { console.log('๐Ÿ”„ ์ƒˆ๋กœ๊ณ ์นจ ๋ฒ„ํŠผ ํด๋ฆญ๋จ'); // Unity ์ƒํƒœ๋ฅผ ๋‹ค์‹œ ํ™•์ธํ•˜๊ณ  ์•„๋ฐ”ํƒ€ ๋ชฉ๋ก๋„ ์ƒˆ๋กœ๊ณ ์นจ requestUnityStatus(); refreshAvatarList(); // ๊ฐ•์ œ๋กœ ์—ฐ๊ฒฐ ์ƒํƒœ๋ฅผ true๋กœ ์„ค์ • (๋‹ค๋ฅธ ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๋‹ค๋ฉด Unity๋Š” ์ž‘๋™ ์ค‘) setTimeout(() => { console.log('๐Ÿ”ง ์ƒˆ๋กœ๊ณ ์นจ ํ›„ ๊ฐ•์ œ๋กœ Unity ์—ฐ๊ฒฐ ์ƒํƒœ๋ฅผ true๋กœ ์„ค์ •'); handleUnityConnected(true); }, 1000); }); } }); console.log('โœ… Avatar Outfit Property Inspector ์Šคํฌ๋ฆฝํŠธ ๋กœ๋“œ ์™„๋ฃŒ');