2024 - Tested with Visual Studio Code v1.95.3 and Unity v2022.3.49f1
First, enable developer options on the device side. On Unity side, "Check Development Build", "Script Debugging" and "Wait For Managed Debugger" then Build and Run. When the application starts, it will show which port it is running on.
Add a new configuration to launch.json file in Visual Studio.
{
"name": "Attach to Unity Device",
"type": "vstuc",
"request": "attach",
"endPoint": "<Local WLAN IP>:<PORT>"
}
Select the new configuration and attach the debugger.
Full sample is in here (9:47): https://www.youtube.com/watch?v=OVWN7RdNk4M