You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gamedev/unity/extensibility/customize-project-files-created-by-vstu.md
+16-42Lines changed: 16 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Customize Project Files Created by VSTU | Microsoft Docs"
3
3
description: Learn to customize project files created by Visual Studio Tools for Unity (VSTU). Review a C# code example.
4
4
ms.custom: ""
5
-
ms.date: "07/26/2018"
5
+
ms.date: "04/19/2021"
6
6
ms.technology: vs-unity-tools
7
7
ms.prod: visual-studio-dev16
8
8
ms.topic: "conceptual"
@@ -14,56 +14,30 @@ ms.workload:
14
14
- "unity"
15
15
---
16
16
# Customize project files created by VSTU
17
-
Visual Studio Tools for Unity provides a Unity-style callback during project file generation. Register with the `VisualStudioIntegration.ProjectFileGeneration` event to modify the project file whenever it's regenerated.
17
+
Unity provides callbacks during project file generation. Implement `OnGeneratedSlnSolution` and `OnGeneratedCSProject` methods using an [`AssetPostprocessor`](https://docs.unity3d.com/ScriptReference/AssetPostprocessor.html)to modify the project or solution file whenever it's regenerated.
18
18
19
19
## Demonstrates
20
-
How to customize the Visual Studio project files generated by Visual Studio Tools for Unity.
20
+
How to customize the Visual Studio project files generated by Visual Studio Tools for Unity.
Copy file name to clipboardExpand all lines: gamedev/unity/extensibility/programming-visual-studio-tools-for-unity.md
+3-6Lines changed: 3 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
2
title: "Programming Visual Studio Tools for Unity | Microsoft Docs"
3
-
description: See examples of programming using the Visual Studio Tools for Unity (VSTU) API. Customize project files created by VSTU. Share the Unity log callback with VSTU.
3
+
description: See examples of programming using the Visual Studio Tools for Unity (VSTU) API. Customize project files created by VSTU.
4
4
ms.custom: ""
5
-
ms.date: "11/04/2016"
5
+
ms.date: "04/19/2021"
6
6
ms.technology: vs-unity-tools
7
7
ms.prod: visual-studio-dev16
8
8
ms.topic: "conceptual"
@@ -20,7 +20,4 @@ In this section, you'll find examples for using the Visual Studio Tools for Unit
20
20
Here are some examples that show how you can use the Visual Studio Tools for Unity APIs.
21
21
22
22
### Customize project files created by VSTU
23
-
Visual Studio Tools for Unity provides a Unity-style callback during project file generation. To learn how you can modify the project file whenever it's regenerated, see [Example: Project file generation](./customize-project-files-created-by-vstu.md).
24
-
25
-
### Share the Unity log callback with VSTU
26
-
Visual Studio Tools for Unity registers a log callback with Unity to be able to stream its console to Visual Studio. If your editor scripts also register a log callback with Unity, the VSTU callback might interfere with it. To learn how you can share the Unity log callback with VSTU, see [Example: Log callback](./share-the-unity-log-callback-with-vstu.md).
23
+
Unity provides callbacks during project file generation. To learn how you can modify project or solution files whenever it's regenerated, see [Example: Project file generation](./customize-project-files-created-by-vstu.md).
Copy file name to clipboardExpand all lines: gamedev/unity/troubleshooting/troubleshooting-and-known-issues-visual-studio-tools-for-unity.md
+34-15Lines changed: 34 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Troubleshooting and known issues (VS Tools for Unity)"
3
3
description: Read about troubleshooting in Visual Studio Tools for Unity. See descriptions of known issues, and learn about solutions to those issues.
4
4
ms.custom: ""
5
-
ms.date: "07/03/2018"
5
+
ms.date: "04/15/2021"
6
6
ms.technology: vs-unity-tools
7
7
ms.prod: visual-studio-dev16
8
8
ms.topic: troubleshooting
@@ -19,9 +19,15 @@ In this section, you'll find solutions to common issues with Visual Studio Tools
19
19
20
20
## Troubleshooting the connection between Unity and Visual Studio
21
21
22
-
### Confirm Editor Attaching is enabled
22
+
### Confirm `Editor Attaching` is enabled or `Code Optimization On Startup` is set to `Debug`
23
23
24
-
In the Unity Menu, select **Edit > Preferences** and then select the **External Tools** tab. Confirm that the **Editor Attaching** checkbox is enabled. For more information, see the [Unity Preferences documentation](https://docs.unity3d.com/Manual/Preferences.html).
24
+
In the Unity Menu, select `Edit / Preferences`.
25
+
26
+
Depending on the Unity version used :
27
+
- Confirm that `Code Optimization On Startup` is set to `Debug`.
28
+
- Or select the `External Tools` tab. Confirm that the `Editor Attaching` checkbox is enabled.
29
+
30
+
For more information, see the [Unity Preferences documentation](https://docs.unity3d.com/Manual/Preferences.html).
25
31
26
32
### Unable to attach
27
33
@@ -54,11 +60,22 @@ For FMOD, there is a workaround, you can pass `FMOD_STUDIO_INIT_SYNCHRONOUS_UPDA
54
60
55
61
## Incompatible project in Visual Studio
56
62
57
-
First, check that Visual Studio is set as your external script editor in Unity (Edit/Preferences/External Tools). Then check that the Visual Studio plugin is installed in Unity (Help/About must display a message like Microsoft Visual Studio Tools for Unity is enabled at the bottom). Then check that the extension is properly installed in Visual Studio (Help/About).
63
+
The very important thing to know is that Visual Studio is saving the “Incompatible” state in project settings and will not try to reload a project until you explicitly use `Reload Project`. So, after each troubleshooting step, make sure you try to re-open the solution and try to right-click on all incompatible projects and choose `Reload Project`.
64
+
65
+
1. Check that Visual Studio is set as your external script editor in Unity using `Edit / Preferences / External Tools`.
66
+
2. Depending on your Unity version:
67
+
- Check that the Visual Studio plugin is installed in Unity. `Help / About` should display a message like Microsoft Visual Studio Tools for Unity is enabled at the bottom.
68
+
- Unity 2020.x+: Check that you are using the latest Visual Studio Editor package in `Window / Package Manager`.
69
+
3. Try deleting all projects/solution files and the `.vs` folder in your project.
70
+
4. Try recreating projects/solution using `Open C# Project` or `Edit / Preferences / External tools / Regenerate Project files`.
71
+
5. Make sure you installed the Game/Unity workload in Visual Studio.
72
+
6. Try to clean the MEF cache as explained [here](#visual-studio-crashes).
73
+
7. Try to re-install Visual Studio (using the Game/Unity workload only to start).
74
+
8. Try to disable third-party extensions in case they could interfere with the Unity extension in `Tools / Extensions`.
58
75
59
76
## Extra reloads, or Visual Studio losing all open windows
60
77
61
-
Be sure to never touch project files directly from an asset processor or any other tool. If you really need to manipulate the project file, we expose an API for that. Please check the [Assembly references issues section](#assembly-reference-issues).
78
+
Be sure to never touch project files directly from an asset processor or any other tool. If you really need to manipulate the project file, we expose an API for that. Please check the [Assembly references issues section](#assembly-reference-or-project-property-issues).
62
79
63
80
If you experience extra reloads or if Visual Studio is losing all open Windows on reload, make sure that you have proper .NET targeting packs installed. Check the following section about frameworks for more information.
64
81
@@ -72,21 +89,23 @@ In the Exception Settings window (Debug > Windows > Exception Settings), expand
72
89
73
90
## On Windows, Visual Studio asks to download the Unity target framework
74
91
75
-
Visual Studio Tools for Unity requires the .NET framework 3.5, which isn't installed by default on Windows 8 or 10. To fix this issue, follow the instructions to download and install the .NET framework 3.5.
92
+
When using the legacy Unity runtime (.NET 3.5 equivalent), Visual Studio Tools for Unity requires the .NET framework 3.5, which isn't installed by default on Windows 8 or 10. To fix this issue, follow the instructions to download and install the .NET framework 3.5.
93
+
94
+
When using the new Unity runtime, .NET targeting packs version 4.6 or 4.7.1 are also required depending on the Unity version. It is possible to use the Visual Studio installer to quickly install them (modify your installation, individual components, .NET category, select all 4.x targeting packs).
76
95
77
-
When using the new Unity runtime, .NET targeting packs version 4.6 and 4.7.1 are also required. It is possible to use the VS2017 installer to quickly install them (modify your VS2017 installation, individual components, .NET category, select all 4.x targeting packs).
96
+
## Assembly reference or project property issues
78
97
79
-
## Assembly reference issues
98
+
If your project is complex reference-wise or if you want to better control this generation step, you can use our [API](../extensibility/customize-project-files-created-by-vstu.md) for manipulating the generated project or solution content. You can also use [response files](https://docs.unity3d.com/Manual/PlatformDependentCompilation.html) in your Unity project and we'll process them.
80
99
81
-
If your project is complex reference-wise or if you want to better control this generation step, you can use our [API](/cross-platform/customize-project-files-created-by-vstu.md) for manipulating the generated project or solution content. You can also use [response files](https://docs.unity3d.com/Manual/PlatformDependentCompilation.html) in your Unity project and we'll process them.
100
+
With recent Visual Studio and Unity versions, the best approach seems to use a custom `Directory.Build.props` file along with your generated projects. You will then be able to contribute to the project structure without interfering with the generation process. More information [here](https://docs.microsoft.com/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets).
82
101
83
102
## Breakpoints with a warning
84
103
85
104
If Visual Studio is unable to find a source location for a specific breakpoint you will see a warning around your breakpoint. Check that the script you are using is properly loaded/used in the current Unity scene.
86
105
87
106
## Breakpoints not hit
88
107
89
-
Check that the script you are using is properly loaded/used in the current Unity scene. Quit both Visual Studio and Unity then delete all generated files (\*.csproj, \*.sln)and the whole Library folder.
108
+
Check that the script you are using is properly loaded/used in the current Unity scene. Quit both Visual Studio and Unity then delete all generated files (\*.csproj, \*.sln), the `.vs` folder and the whole Library folder. You can find more information on C# debugging on the Unity [website](https://docs.unity3d.com/Manual/ManagedCodeDebugging.html).
90
109
91
110
## Unable to debug Android players
92
111
@@ -96,13 +115,13 @@ Wifi is versatile but super slow compared to USB because of latency. We saw a la
96
115
97
116
USB is super-fast for debugging, and Visual Studio Tools for Unity is now able to detect USB devices, and talk to the adb server to properly forward ports for debugging.
98
117
99
-
## Issues with Visual Studio 2015 and IntelliSense or code coloration
118
+
## Issues with IntelliSense or code coloration
100
119
101
-
Try upgrading your Visual Studio 2015 to update 3.
120
+
Try upgrading your Visual Studio to the latest version. Try the same same troubleshooting steps as for [Incompatible projects](#incompatible-project-in-visual-studio).
102
121
103
122
## Known issues
104
123
105
-
There are known issues in Visual Studio Tools for Unity that result from how the debugger interacts with Unity's older version of the C# compiler. We're working to help fix these problems, but you might experience the following issues in the meantime:
124
+
There are known issues in Visual Studio Tools for Unity that result from how the debugger interacts with Unity's older version of the C# compiler. We're working to help fix these problems, but you might experience the following issues in the meantime:
106
125
107
126
- When debugging, Unity sometimes crashes.
108
127
@@ -112,11 +131,11 @@ Try upgrading your Visual Studio 2015 to update 3.
112
131
113
132
## Report errors
114
133
115
-
Please help us improve the quality of Visual Studio Tools for Unity by sending error reports when you experience crashing, freezes, or other errors. This helps us investigate and fix problems in Visual Studio Tools for Unity. Thank you!
134
+
Please help us improve the quality of Visual Studio Tools for Unity by sending error reports when you experience crashing, freezes, or other errors. This helps us investigate and fix problems in Visual Studio Tools for Unity. Thank you!
116
135
117
136
### How to report an error when Visual Studio freezes
118
137
119
-
There are reports that Visual Studio sometimes freezes when debugging with Visual Studio Tools for Unity, but we need more data to understand this problem. You can help us investigate by following the steps below.
138
+
There are reports that Visual Studio sometimes freezes when debugging with Visual Studio Tools for Unity, but we need more data to understand this problem. You can help us investigate by following the steps below.
120
139
121
140
##### To report that Visual Studio freezes while debugging with Visual Studio Tools for Unity
0 commit comments