Its nothing to do with source but builds! That’s the whole point. In order for the clients to easily access user settings and also not to move the build or parts of the build around and brake it, the settings and content need to be in the project root. Its not purely just clients though its also for ease of access for myself and other users in the company. If I want to change an ini setting I want as few clicks as possible and again the project root is the shortest root.
Note:
The following is simply proof-of-concept stuff. It only applies to Unity 2019.4.28 and com.unity.ide.visualstudio (2.0.16), though as changes are being made to a single file it should be possible to extrapolate to newer versions.
I made some progress with a custom version of com.unity.ide.visualstudio package. I embedded the package in the package folder and made two changes to ProjectGeneration.cs. These changes placed all the VS files ( including .vs and obj folders) into a subfolder called ‘solution’ - though i’m lazy and the code doesn’t create that folder, you have to do it yourself at the moment.
Unfortunately while this appears to work with a test project and all files can be accessed via the ‘Solution Explorer’ in VS, it fails to generate/populate the ‘Unity Project Explorer’ section. Not sure why that is, and I don’t think the VS Unity plugin code is open source so hard to check.
If I were to guess its looking for the solution file in the project root or worse it expects all the solution files to be in project root which means back to square one. This is the main reason why I hoped that Unity might implement this feature to choose where to create the solution files as they will understand the situation better than anyone else. For all I know what I want to achieve is impossible and a Unity Tech familiar with this stuff would know and could just say.
Edit
I made a few more changes so that the project sln file stayed in root folder while the csproj files were placed in a subfolder called ‘VSProjectFiles’ ( again I haven’t bothered to create the folder, you have to do it by hand ). This is quite nice and tidy and again works fine (for the few limited tests I did) with the ‘Solution Explorer’, auto-complete etc, but still nothing in ‘Unity Project Explorer’. Ultimately I guess this might not matter too much since everything else appears to work, its just nice to be able to browse the project as its presented in Unity browser.
So not sure what is required for VS to populate the ‘Unity Project Explorer’ and not sure its possible to find out. Not that this is a great solution to the problem anyway since it means you have to use a customised version of Unity’s visualStudio.package and embed it in every project.
Oh just discovered that Unity has an AssetPostprocessor for SLN and CSProject generation. The VisualStudio Unity Docs were useful to discover this. While not very practical as it simply passes you the generated file, it could be used to modify the file, but sadly the filepath is fixed so ultimately has no use for this purpose. You can’t even move the file as it doesn’t exist at this point in the processes and i’m not sure if there is a relevant hook later but before Unity opens visualstudio.
8504300–1132649–ProjectGeneration.7z (8.58 KB)
8504300–1132667–ProjectGeneration_VSProjectFiles.7z (8.62 KB)