The man point of the issue is that people who have been able to attach debuggers to their Unity projects via their usual Editor debugging flow- whether it’s precisely the steps outlined above, or equivalent- are unable to attach the debugger to projects incorporating Lightship because attempting to attach the debugger provokes an automatic build of debuggable binary, and this automatic process fails with copious errors apparently deriving from an unavailable or incorrectly linked Google library.
If there are additional Lightship-specific steps or requirements, e.g. particular editor/VS combinations or manual execution of steps that Unity and VS’ mutual plugins/modules typically handle, it would be good to have those on record.
If you connect the debugger via the Debug → Attach Unity Debugger menu as you did in your post above @Gilberto , Visual Studio doesn’t try to build anything first and it all works as expected.
The build errors all stem from the Google.Protobuf.3.19.4 plugin (Niantic.Google.Protobuf.dll) not being correctly linked in the ARDK VS project. I noticed this because of the warning icon on the reference:
I’ve put together a work around that seems to be working though…
Drop the attached script into an Editor folder in your project, then hit Assets → Open C# Project to force Unity to regenerate the VS solution and project files. ARDKFixAssetPostprocessor.cs (5.0 KB)
This time the script will include the google protobuf library into the ARDK project via NuGet.
I found the first time after you do this VS might still fail to connect (It doesn’t seem to have refreshed the loaded nuget packages yet or something…) so if you do get a fail at this point just open up the References tab of the ARDK project and select the Google.Protobuf item.
Just selecting it was enough to cause visual studio to realise the nuget package is there and everything worked from then onwards. You will probably see the yellow warning icon on this disappear too so you know it’s worked.
Just as with any hacky workaround, while it works, the approach isn’t ideal. Hopefully come the next release Niantic will have sorted it so we can have their dll properly referenced by default in the project without any issues.
Cool. I’d imagine I can fix this on my end, but fyi that script is throwing a Assets\Editor\ARDKFixAssetPostprocessor.cs(30,71): error CS1503: Argument 1: cannot convert from 'string' to 'char'
on my setup. Looks like maybe my String.split can’t handle strings as split tokens. Changing the argument to char single-quotes resolves it.
Edit: VS still showing the ! triangle and Referenced Component Could Not Be Found warnings after opening twice and clicking both the Google.Protobuf and Niantic.Google.Protobuf References. Any VS version restrictions on this script? Currently using Unity 2021.1 / VS 2019 (16.11.13)
Oddly, looks like it is there in the NuGet management interface.
Is there anything to the fact that the two Protobuf Resources have Copy Local: False in their properties, while all the non-erroring references have Copy Local: True?
Noticing the header warning and letting it Restore missing packages fixed the raw Google.Protobuf, but not the Niantic.Google.Protobuf. Haven’t checked if this is enough yet.
Nice spot, weird I wasn’t seeing that on my setup but I’m glad you caught it - thanks.
I’ll re-upload the file with that edit in the original post.
(@NNDev if you could verify the updated file looks good on your setup that would be ace. Thanks!)
I’d already made the cited tweak to the script on my end by the time you posted, so without rolling back version control or bombing things out manually I can’t verify that your tweak, if it’s any different, also works, but fwiw dropping the new script in doesn’t blow up anything that was fixed by the local edit.
Looks like I can successfully Attach To Unity as well now, even though only one of the two Protobufs has been properly resolved.
For those following along,
Tools → NuGet Package Manager → Manage NuGet Packages For Solution is where I pulled my previous screenshot, which had the notification header which ultimately prompted a re-download that actually resolved the base GoogleProtobuf package (after MattMurton’s script let the project know to look for it).
Ok yea makes sense, sorry I was misunderstanding the problem.
And yea both of you are right, the problem seems to be the ARDK is with the Google.Protobuf version is trying to use, definitely a bug on the ARDK.
Here is my work around, though admittedly its not a super clean one either. Try replacing the protobuf with a recent one. This will only work if you have “Script for Debugging” check mark on Unity’s build settings btw.
Download the Google.Protobuf package from Nuget ( Tools → NuGet Package Manager → Manage NuGet Packages)
Replace the one included by the ARDK with that one, this is harder to explain than do but here goes:
The install location for the correct package is <ProjectRoot>/Packages/Google.Protobuf.3.21.2/lib/net5.0/
Take the .dll and .xml file found there, rename them to Niantic.Google.Protobuf.dll and Niantic.Google.Protobuf.xml.
Move the files to <ProjectRoot>/Assets/ARDK/Plugins/Niantic.Protobufs/Google.Protobuf.3.19.4/net45/ and replace the ones there.
Do the same for the .pdb file in the package and the one in Library/ScriptAssemblies/ :
Rename file <ProjectRoot>/Packages/Google.Protobuf.3.21.2/lib/net5.0/Google.Protobuf.pdb to include Niantic, so: Niantic.Google.Protobuf.pdb and put it in the <ProjectRoot>/Library/ScriptAssemblies/ folder.
Note: You might have to reopen Unity editor for it to recognize script components.
Let me know if this works for you all.
Sorry again about the confusion and delay on responses.
For the moment, I attach directly through the Visual Studio menu without using the Debug button.
Hopefully this problem will be solved permanently in the next versions of ARDK.