I have developed an application for hololens with Unity that uses the Hololens' depth camera. I built it with il2cpp scripting backend and it runs well on the Hololens when I launch it from Visual Studio 2017 (community). But I want to be able to debug the app (and have the output in visual studio console) while it is running on the Hololens (because I need the camera frame to be received to see how it works).
Moreover, I want to be able to set breakpoints in my .cs scripts files in my #UWP script parts.
I have been searching for a long time on Microsoft documentation and didn't find the specific answers I was looking for.
The Unity - Manual and also Microsoft - Managed Debugging with Unity IL2CPP is your friend! Check the section Debugging in the Player
In short:
In the player settings enable the capabilities PrivateNetworkClientServer, InternetClientServer
In the build settings enable Development Build, ScriptDebugging and Wait For Managed Debugger.
Build your project to a solution. Open the solution in VisualStudio.
With the HL connected run it on Device. (As debug from VisualStudio or by deploying and starting it on the device itself). Alternatively via WiFi enter the IP of the HoloLens .. just takes a bit longer to deploy of course
Wait for the pop-up.
Open any script by double click from Unity in a second VisualStudio instance (so the project's c# solution is loaded)
Here you also set the breakpoints
Go to Debug-> Attach Unity Debugger
select the HoloLens and attach the debugger
on the HL close the pop-up
You can now set breakpoints and debug c# code as usual while the HoloLens is actually running the Il2CPP solution.
I found the answer to my problem!
In order to debug c# code directly running on the Hololens, I did as follow:
In Unity :
Build Setting -> Player settings -> Other settings -> Scripting backend = .NET
Build Settings :
Build configuration Debug
check Copy reference
check Unity c# project
check development build
Then you can build
In Visual Studio 2017
Debug - x86 - Device (or remote machine)
If needed : In Solution Explorer -> For each solution -> alt+Enter -> Under Build tab check Allow unsafe code
Then you can set your break points where ever you want !
Hope this helps
Just adding a note in here, if anyone should drop by: The accepted answer is not seen as a solution going forward from 2019 as .NET backend is deprecated: See ths approach for debugging:
https://learn.microsoft.com/en-us/archive/blogs/appconsult/how-to-debug-unity-projects-with-il2cpp-backends-on-the-hololens
Related
I'm trying to run instrumentation profiler on my Unity build to know which functions are called the most and take the most time.
I have created librairies in C# which are imported in Unity, I can debug them without problems but am not able to start the visual studio profiler to instrument them.
I couldn't find an instrumentation function in Unity. Or at least it seems to crash and I get many exceptions after a few minutes of running. (ThreadDeserializer should not parse more data once it has been marked as terminated)
I have tried:
attach VS to Unity play mode but the instrumentation option isn't active
build in Unity with Debug options, PDB copied, deep profiling enabled, when trying to profile the .exe from Visual Studio I get
Unable to obtain debugging information.
PRF0002: The instrumentation with those options has failed
I also try to run my application .exe and attach VS's debugger but the instrumentation option is available.
Am I missing something?
I am trying to learn Unity3d game development and would really appreciate some help here...
My issue is that upon typing a word such as transform (e.g transform.Rotate), instead of Intellisense lighting it up as a keyword, it highlights other suggestions such as OnTransformChildrenChanged()
or OnTransformParentChanged().
Any possible way of fixing this?
I just downloaded Visual Studio Code and the extensions needed to work with Unity3d.
I also have Unity3d's code editor set to Visual Studio Code via Preferences -> External Tools -> External Tool Editor.
I have watched multiple tutorials and downloaded multiple extensions for unity tools in VSCode, but still no fix to the Intellisense.
first download and install this runtime app
Windows: .NET Framework 4.6 Targeting Pack
macOS: Download .NET SDK.
download link all package for unity (package).
Open up Unity Preferences>-> External Tools>-> as External Script Editor.
after this choice the browse for the Visual Studio Cod executable .
The Visual Studio Code executable can be found at mac (osx)
/Applications/Visual Studio Code.app.
or at windows
C:\users{username}\AppData\Local\Programs\Microsoft VS Code\Code.exe
by default.
after restart both application
double click on c# file and choice VS code for ide.
I realize what my problem was, it had to do with HOW I was opening my C# scripts.
In Unity, instead of double clicking the C# script to open it up in VSCode, Right click the Assets Folder and then choose Open C# Script.
This solved the problem I was having completely.
How do you debug C# in Visual Studio Code on Windows?
I have an aspnet core project set up, I can build and edit it in VS Code and it works great.
I've installed the C# Omnisharp extension as per all of the getting started guides show and it's really easy to get going, except for one hugely important thing...
How do you actually debug it on Windows? Every article / blog post that I've come across only shows C# debugging with OSX or Linux.
Debugging with Mono doesn't work, I get the following:
Mono Debug is not supported on this platform (Win32NT).
And you can't install the Mono-Debugger extension on Windows - only OSX and Linux. Which makes sense, but what are the steps to do this with Windows?
I must be missing something really easy - how do I set up C# debugging with Visual Studio Code on Windows?
I've stumbled upon it myself and found the answer in instalation guide of debugger:
https://marketplace.visualstudio.com/items?itemName=Unity.unity-debug
You should check whether you have launch.json file already. If so, delete it and after clicking a cogwheel on top of debug view, select Unity Editor from dropdown.
There is also a VSCode Unity plugin, which may overwrite the file every time you start the game in the editor. To disable this uncheck the "Edit/Preferences/VSCode/Always Write Launch File" checkbox
I recently got a new computer but I chose to install VS2015 after reinstalling Unity. I previously used monodevelop but thought I'd give VS a go (partially because it became the default program when opening scripts through Unity and I can't seem to change that).
I am however having a few problems due to the intellisense/auto complete function not working. I've read through a lot of answers on here but nothing seems to help.
My suggestion would be to rebuild your solution files.
From your projects root folder, copy Assets and Project Settings ONLY over to a new directory. From here open up one of your scenes, Unity will import assets and build the scene.
Once open, go to Edit -> Preferences -> External Tools and make sure that Visual Studio 2015 is selected as the External Script Editor and then go Assets -> Sync MonoDevelop Project (Ignore the name MonoDevelop!)
See if that works for you.
Failing that follow the guide here and note what version of Unity you are using as there are different steps for pre 5.2 Getting Started with Visual Studio Tools for Unity
And if that doesn't work, it's going to be a problem with your Visual Studio install. I've had this before even on a new install. So try a re-install as a last resort.
So the problem is when i try to setup breakpoint on line with Binding markup extension I get error telling me that it's unable to set breakpoint in this location.
Visual Studio
Microsoft Visual Studio Ultimate 2012
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.5.50709
Installed Version: Ultimate
Platform settings
Platform targets are x86 for all except Silverlight ( selection box locked there)
Debug info is set to full everywhere.
Debug settings
Cleaned up and rebuild solution with no errors.
Go to line with Binding press F9 or Debug->Toggle breakpoint and see:
When I had this I error I could usually solve it by doing the following things:
Make sure that Silverlight debugging is enabled: Project properties -> Web -> Debuggers -> Activate the Silverlight CheckBox.
Use the Internet Explorer for debugging. Although it may work with other browsers, I often ran into strange problems like the Breakpoints not being correctly set.
Most important:
Clear the IE browser cache. It is most likely possible that the browser has cached an older version of your Silverlight application and for some reason does not use the latest version of it.
If this works for you, you miht also consider to configure the caching of the temporary internet files to "Never" to make sure that IE always uses the most recent version of your SL application.
You should provide more details for a accurate solution. By experience, you should try:
1 - Check the Configuration Manager and assert all projects are building for Debug, and targeting x86. (x64 has some debugging limitations).
2 - In Project Properties Page > Build > Advanced, assert Debug Info is set to full.
3 - Clean and rebuild your solution. (Worked for me on ASP.NET).
Also, when I couldn't solve this problem, i used a workaround; Create an event handler for DataBind event, and break the code there. Then step into. Eventually you'll step into the xaml file.
Please, mark answer if it helps. Thanks.
The way if i fixed it by selecting Internet Explorer as browser to run into. Then set the binding reakpoint while it was running. Since then it is working well.