Art-Net・DMX関連を実装とチュートリアルの削除 - #3
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes Unity HDRP template/tutorial “Readme” assets and introduces an Art-Net DMX receive pipeline with an Editor DMX monitoring window, plus small scene/settings updates to support it.
Changes:
- Removed
Assets/TutorialInfo/*readme/editor/layout assets from the Unity template. - Added
Core.Network.ArtNetReceiver+DmxBufferand placed anArtNetReceiverGameObject intoOutdoorsScene. - Added an EditorWindow (
DmxMonitorWindow) to visualize DMX values during Play Mode; adjusted sky/fog profile parameters.
Reviewed changes
Copilot reviewed 20 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| LightVisualizer/Assets/TutorialInfo/Scripts/Readme.cs.meta | Removes template readme script meta. |
| LightVisualizer/Assets/TutorialInfo/Scripts/Readme.cs | Removes template Readme ScriptableObject type. |
| LightVisualizer/Assets/TutorialInfo/Scripts/Editor/ReadmeEditor.cs.meta | Removes template custom editor meta. |
| LightVisualizer/Assets/TutorialInfo/Scripts/Editor/ReadmeEditor.cs | Removes template readme inspector/auto-layout editor script. |
| LightVisualizer/Assets/TutorialInfo/Layout.wlt.meta | Removes template layout meta. |
| LightVisualizer/Assets/TutorialInfo/Layout.wlt | Removes template editor layout. |
| LightVisualizer/Assets/TutorialInfo/Icons/Help_Icon.png.meta | Removes template icon meta. |
| LightVisualizer/Assets/TutorialInfo/Icons/HDRP.png.meta | Removes template icon meta. |
| LightVisualizer/Assets/Settings/SkyandFogSettingsProfile.asset | Updates HDRP sky/fog profile parameters. |
| LightVisualizer/Assets/OutdoorsScene.unity | Adds an ArtNetReceiver GameObject to the scene. |
| LightVisualizer/Assets/Editor/Windows/DmxMonitorWindow.cs.meta | Adds meta for the DMX monitor editor window script. |
| LightVisualizer/Assets/Editor/Windows/DmxMonitorWindow.cs | Adds an EditorWindow to display DMX channels in Play Mode. |
| LightVisualizer/Assets/Editor/Windows.meta | Folder meta update for Assets/Editor/Windows. |
| LightVisualizer/Assets/Editor.meta | Folder meta update for Assets/Editor. |
| LightVisualizer/Assets/Core/Network/DmxBuffer.cs.meta | Adds meta for the DMX buffer script. |
| LightVisualizer/Assets/Core/Network/DmxBuffer.cs | Adds buffer/storage for multi-universe DMX data with locking. |
| LightVisualizer/Assets/Core/Network/ArtNetReceiver.cs.meta | Adds meta for the Art-Net receiver script. |
| LightVisualizer/Assets/Core/Network/ArtNetReceiver.cs | Adds UDP Art-Net receive thread and DMX packet parsing. |
| LightVisualizer/Assets/Core/Network.meta | Folder meta update for Assets/Core/Network. |
| LightVisualizer/Assets/Core.meta | Folder meta update for Assets/Core. |
| LightVisualizer/.idea/.idea.LightVisualizer/.idea/copilot.data.migration.ask2agent.xml | Adds IDE state/config related to Copilot migration. |
Files not reviewed (1)
- LightVisualizer/.idea/.idea.LightVisualizer/.idea/copilot.data.migration.ask2agent.xml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private void ProcessPacket(byte[] data) | ||
| { | ||
| if (data == null) return; | ||
|
|
||
| // ヘッダーの検証 | ||
| for (int i = 0; i < 8; i++) | ||
| { | ||
| if (data[i] != _artNetHeader[i]) return; | ||
| } | ||
|
|
||
| // OpCodeの検証 | ||
| ushort opCode = BitConverter.ToUInt16(data, 8); | ||
| if (opCode != 0x5000) return; // ArtDMXパケットのみ処理 | ||
|
|
||
| // ユニバースの計算 | ||
| int universe = data[14] | (data[15] << 8); | ||
|
|
||
| int length = (data[16] << 8) | data[17]; | ||
| if (length > 512) return; | ||
|
|
||
| // DMXデータの更新 | ||
| byte[] dmxData = new byte[length]; | ||
| Buffer.BlockCopy(data, 18, dmxData, 0, length); | ||
|
|
There was a problem hiding this comment.
ProcessPacket reads fixed offsets (0..17) and copies from offset 18 without first validating data.Length. A short/invalid UDP packet will cause IndexOutOfRangeException or ArgumentException during BlockCopy. Add minimum-length checks (and ensure data.Length >= 18 + length) before accessing these indices.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| { | ||
| int index = startIndex + row * columns + col; | ||
| byte value = index < dmxData.Length ? dmxData[index] : (byte)0; | ||
|
|
||
| GUIStyle cellStyle = new GUIStyle(GUI.skin.box) | ||
| { | ||
| fixedWidth = 30, | ||
| fixedHeight = 30, | ||
| alignment = TextAnchor.MiddleCenter, | ||
| }; | ||
| cellStyle.normal.textColor = Color.white; |
There was a problem hiding this comment.
DrawDmxGrid allocates a new GUIStyle for every cell on every repaint (512 allocations per universe per frame), which will create avoidable GC churn in the Editor. Cache/reuse a single cell style (or a small set of styles) instead of constructing it inside the inner loop.
| // DMXデータを取得 | ||
| byte[] dmxData = receiver.DmxBuffer.GetDmxDataSnapshot(); | ||
|
|
||
| // 選択されたユニバースの開始インデックス | ||
| int startIndex = _selectedUniverse * DmxBuffer.ChannelsPerUniverse; | ||
|
|
||
| DrawDmxGrid(dmxData, startIndex); |
There was a problem hiding this comment.
GetDmxDataSnapshot() allocates a full copy of the DMX buffer each OnGUI call; combined with Repaint() every frame this can generate steady GC pressure. Consider returning a reused buffer, a per-universe snapshot, or exposing a read-only view with locking so the window can render without allocating every frame.
| // ヘッダー行の描画 | ||
| EditorGUILayout.BeginHorizontal(); | ||
| for (int col = 0; col < columns; col++) | ||
| { | ||
| GUILayout.Label($"Column {col + 1}", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(30)); | ||
| } | ||
| EditorGUILayout.EndHorizontal(); | ||
|
|
||
| // DMXチャンネルの描画 | ||
| for (int row = 0; row < rows; row++) | ||
| { | ||
| EditorGUILayout.BeginHorizontal(); | ||
|
|
||
| // 行の先頭チャンネル番号 | ||
| int startChannel = row * columns + 1; | ||
| GUILayout.Label($"{startChannel:000}", EditorStyles.boldLabel, GUILayout.Width(40)); | ||
|
|
There was a problem hiding this comment.
The header row draws 32 column labels, but each data row also renders an extra leading channel-number label, causing the grid to be visually misaligned. Add an empty/header cell (matching the 40px width) or otherwise account for the row-label column so columns line up.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| private void Awake() | ||
| { | ||
| this.DmxBuffer = new DmxBuffer(); | ||
| } | ||
|
|
There was a problem hiding this comment.
This PR removes the Readme ScriptableObject script and HDRP tutorial icon assets, but Assets/Readme.asset still references the deleted script GUID (fcf7219...) and icon GUID (d19680...). This will produce a missing-script asset on import. Either delete Assets/Readme.asset or update it to a remaining script/icon.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="Ask2AgentMigrationStateService"> | ||
| <option name="migrationStatus" value="COMPLETED" /> | ||
| </component> | ||
| </project> No newline at end of file |
There was a problem hiding this comment.
copilot.data.migration.ask2agent.xml looks like a local JetBrains/Rider state file rather than project source. Consider adding it to the appropriate .idea/.gitignore (or repo root .gitignore) and removing it from version control to avoid churn across developers.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@otoyuzu705 I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you. |
…angeException Co-authored-by: otoyuzu705 <107416827+otoyuzu705@users.noreply.github.com>
Guard ProcessPacket against short/malformed UDP packets
|
@otoyuzu705 I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you. |
…add to .gitignore Co-authored-by: otoyuzu705 <107416827+otoyuzu705@users.noreply.github.com>
|
@otoyuzu705 I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: otoyuzu705 <107416827+otoyuzu705@users.noreply.github.com>
|
@otoyuzu705 I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: otoyuzu705 <107416827+otoyuzu705@users.noreply.github.com>
Remove JetBrains Rider local state file from version control
Delete Readme.asset with dangling GUID references
Fix DMX monitor grid header misalignment
Art-Net受信用コンポーネント
Assets/Core/Network/ArtNetReceiver.csDMXチャンネルの管理用クラス
Assets/Core/Network/DmxBuffer.csDMXチャンネルの値をグリッド形式で視覚化するエディターツール
Assets/Editor/Windows/DmxMonitorWindow.csUnity標準のTutorialInfoを削除