Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a way to auto-attach Unity debugger #29

Open
JonnyOThan opened this issue Sep 3, 2024 · 0 comments
Open

Find a way to auto-attach Unity debugger #29

JonnyOThan opened this issue Sep 3, 2024 · 0 comments

Comments

@JonnyOThan
Copy link
Contributor

https://developercommunity.visualstudio.com/t/Provide-a-way-to-automate-attaching-Unit/10498892?space=8&q=unity+tools+autocomplete

Seems like it requires a vs extension:

// All needed types are in Microsoft.VisualStudio.Shell.Interop namespace
var debugger = (IVsDebugger4)GetService(typeof(IVsDebugger));

// We need to pass a special type to 'bstrOptions' below
const string prefix = "SyntaxTree.VisualStudio.Unity";
var debuggerHostAssembly = AppDomain.CurrentDomain.GetAssemblies(). First(a => a.GetName(). Name == prefix);
var debuggerHostType = $"{prefix}. Debugger.DebugEngineHost, {debuggerHostAssembly.FullName}";

// you can add several targets if you want
var targets = new VsDebugTargetInfo4[1];

targets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION. DLO_Custom;
targets[0].bstrExe = "Unity";
targets[0].fSendToOutputWindow = true;
targets[0].guidLaunchDebugEngine = new Guid("F18A0491-A310-4822-B12F-12CC30404EEC"); // this is the Unity Debugger Engine Guid
targets[0].bstrOptions = $"127.0.0.1:56872|{debuggerHostType}";                      // ip/port of the local or remote Editor/Player

// Attach to targets
var results = new VsDebugTargetProcessInfo[targets. Length];
debugger. LaunchDebugTargets4((uint)targets. Length, targets, results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant