Streamingle_URP/Streamdeck/DEBUG_MARKER_BUTTON.md
2025-10-28 00:02:17 +09:00

7.1 KiB (Stored with Git LFS)

OptiTrack Marker Button Debug Guide

Current Status

All code is properly implemented and in place:

  • SystemController.cs has marker toggle methods
  • StreamDeckServerManager.cs routes marker messages
  • manifest.json defines the OptiTrack Marker Toggle action
  • plugin/index.js has marker button handler
  • Icon images are present (optitrack_marker_icon.png, optitrack_marker_icon_off.png)

Testing Steps

1. Deploy the Plugin

Run the deployment script:

cd c:\Users\qscft\OneDrive\문서\Streamingle_URP\Streamdeck
deploy-plugin.bat

The script will:

  • Auto-elevate to administrator privileges
  • Stop StreamDock process
  • Backup and replace plugin files
  • Restart StreamDock
  • All messages are in English now (no garbling)

2. Add Marker Button to StreamDock

IMPORTANT: You must add a NEW button, not use an existing camera button!

  1. Open StreamDock software
  2. Find the "OptiTrack Marker Toggle" action in the action list
  3. Drag it to an empty button slot on your StreamDeck
  4. The button should show the marker icon with title "마커\nON"

3. Test the Button

  1. Make sure Unity is running with the scene loaded
  2. Check Unity Console for: [StreamDeckServerManager] WebSocket 서버 시작됨 (포트: 10701)
  3. Click the marker button on StreamDock

Expected Debug Output

StreamDock Plugin Console (if accessible)

When button is first added (willAppear event):

✅ [MARKER] OptiTrack 마커 토글 등록: <context-id>
✅ [MARKER] Action UUID: com.mirabox.streamingle.optitrack_marker_toggle
✅ [MARKER] Settings: {"actionType":"optitrack_marker_toggle","currentState":0}
🎯 최종 actionType: optitrack_marker_toggle
💾 설정 저장됨: {"actionType":"optitrack_marker_toggle"}

When button is clicked (keyDown event):

🔍 [DEBUG] handleButtonClick 호출됨
🔍 [DEBUG] context: <context-id>
🔍 [DEBUG] settings: {"actionType":"optitrack_marker_toggle","currentState":0}
🔍 [DEBUG] actionType: optitrack_marker_toggle
🎯 OptiTrack 마커 토글 실행
📤 Unity에 OptiTrack 마커 토글 요청 전송: {"type":"toggle_optitrack_markers"}
🔍 Unity 연결 상태: true
🔍 Unity 소켓 상태: true
✅ 메시지 전송 완료
🎨 버튼 상태 업데이트: OFF

Unity Console

When marker button is clicked:

[StreamDeckServerManager] 수신된 메시지: toggle_optitrack_markers
[StreamDeckServerManager] 시스템 명령어 실행: toggle_optitrack_markers
[SystemController] 명령어 실행: toggle_optitrack_markers
[SystemController] OptiTrack 마커 표시: True

Troubleshooting

Issue: Still receiving camera messages

Symptom: Unity log shows {"type":"switch_camera","data":{"camera_index":0}}

Diagnosis:

  1. Check if you're clicking the correct button
  2. The old camera buttons will still send camera messages
  3. You need to add a NEW "OptiTrack Marker Toggle" button

Solution:

  1. Remove the button you're testing
  2. Add a fresh "OptiTrack Marker Toggle" action from the action list
  3. Make sure the action name in StreamDock UI says "OptiTrack Marker Toggle"

Issue: Button shows "Camera" instead of "마커\nON"

Symptom: Button title doesn't update to marker title

Cause: You added a camera button, not a marker button

Solution: Add the correct "OptiTrack Marker Toggle" action

Issue: No debug output in Unity

Symptom: Clicking button doesn't produce any Unity logs

Possible Causes:

  1. Unity WebSocket server not running
  2. StreamDock plugin not connected to Unity
  3. Button settings not properly registered

Debug Steps:

  1. Check Unity Console for: [StreamDeckServerManager] WebSocket 서버 시작됨
  2. Check for: [StreamDeckServerManager] 새 연결 수락됨
  3. If no connection message, restart Unity
  4. Redeploy plugin and restart StreamDock

Issue: Button state doesn't toggle

Symptom: Button stays on same icon/title after clicking

Cause: Button state system requires both images and proper setState handling

Check:

  1. Verify both images exist: optitrack_marker_icon.png and optitrack_marker_icon_off.png
  2. Check manifest.json has DisableAutomaticStates: false
  3. Check States array has 2 state definitions

Accessing StreamDock Plugin Console

StreamDock is based on Electron, similar to VS Code. Try these methods:

Method 1: Developer Tools Shortcut

  • Press F12 while StreamDock is focused
  • Or Ctrl+Shift+I
  • If it works, you'll see Chrome DevTools with Console tab

Method 2: Debug via Log Files

StreamDock may write logs to:

  • %APPDATA%\Hotspot\StreamDock\logs\
  • Check the latest log file for JavaScript console output

Method 3: Unity Console Only

If you can't access StreamDock console, use Unity Console exclusively:

  • The message type received by Unity tells you everything
  • If you see toggle_optitrack_markers → plugin is working correctly
  • If you see switch_camera → wrong button is being clicked

What Each ActionType Should Send

Button Action actionType Setting Message to Unity Unity Handler
Camera Switch camera {"type":"switch_camera","data":{"camera_index":0}} HandleCameraSwitch
Item Control item {"type":"item_toggle","data":{...}} HandleItemToggle
Event Control event {"type":"event_execute","data":{...}} HandleEventExecute
Avatar Outfit avatar_outfit {"type":"avatar_outfit_change","data":{...}} HandleAvatarOutfitChange
Marker Toggle optitrack_marker_toggle {"type":"toggle_optitrack_markers"} HandleSystemCommand

Verification Checklist

Before reporting a bug, verify:

  • Deployed latest plugin using deploy-plugin.bat
  • StreamDock was restarted after deployment
  • Unity is running with scene loaded
  • Added NEW "OptiTrack Marker Toggle" button (not existing camera button)
  • Button title shows "마커\nON" or "마커\nOFF"
  • SystemController GameObject exists in Unity scene
  • Unity WebSocket server is running on port 10701
  • Unity Console shows connection from StreamDock plugin

File Locations Reference

Plugin Source Files

Streamdeck/com.mirabox.streamingle.sdPlugin/
├── manifest.json (Line 115-137: Marker action definition)
├── plugin/index.js (Line 94-101: Marker registration, Line 329-330: Marker handler)
└── images/
    ├── optitrack_marker_icon.png (ON state)
    └── optitrack_marker_icon_off.png (OFF state)

Unity Files

Assets/Scripts/Streamdeck/
├── SystemController.cs (Line 30-50: Marker toggle methods)
└── StreamDeckServerManager.cs (Line 347-351: Marker message routing)

Next Steps After Successful Test

Once marker button is working correctly:

  1. Document the successful configuration
  2. Add more system functions using the same pattern
  3. Create icon sets for new functions
  4. Update SYSTEM_CONTROLLER_GUIDE.md with new functions