Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
6
Question by user-2910 (google) · Mar 24, 2011 at 05:23 PM · visualstudio

Change Visual Studio Solution generated by Unity

Is it possible to modify the Visual Studio solution and project that is generated by unity? What I would like to do is hookup our code analysis to the Visual Studio solution automatically when generating the solution. I can't seem to find a VS project template that Unity uses to generate the project, so I'm not sure if this is even possible.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Mar 24, 2011 at 06:21 PM 0
Share

Well, the problem is that Unity recreates the solution when any project updates happens (like new scripts are added or old ones have been changed). A template would be nice but i'm not sure if there is one. I just use C# Express so i don't even have it integrated in Unity. $$anonymous$$aybe someone else have a solution or workaround.

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by ricardo_arango · Sep 01, 2011 at 04:00 PM

You can use an undocumented AssetPostprocessor that is called after the solution synchronization.

This is an example script that fixes the Visual Studio Version Selector Problem in Unity 3.4 (double clicking won't open the solution):

 using UnityEngine;
 using UnityEditor;
 using System;
 using System.IO;
 using System.Text;
 
 public class PostProcessVisualStudioCSProject : AssetPostprocessor
 {
     static public void OnGeneratedCSProjectFiles () {
         // Open the solution file
         string projectDirectory = System.IO.Directory.GetParent(Application.dataPath).FullName;;
         string projectName = Path.GetFileName(projectDirectory);
         string slnFile = Path.Combine(projectDirectory, string.Format("{0}.sln", projectName));
 
         try {
             StringBuilder sb = new StringBuilder();
             string line = null;
             using (StreamReader sr = new StreamReader(slnFile)) {
                 while ((line = sr.ReadLine()) != null)
                     sb.AppendLine(line.Replace("\n", Environment.NewLine).Replace("\r", Environment.NewLine).Replace("# Visual Studio 2008", "# Visual Studio 2010"));
             }
             using (StreamWriter sw = new StreamWriter(slnFile, false, Encoding.UTF8)) {
                 sw.Write(sb.ToString());
             }
         }
         catch (Exception e) {
             Console.WriteLine("The file could not be read:");
             Console.WriteLine(e.Message);
         }
     }
 }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Keld lykke · Apr 18, 2011 at 09:55 PM

No. I reckon it is not.

Lucas Meier originally made a script on his blog (see it here) that could generate the visual studio project file.

Since Lucas became a Unity employee, I guess the current built-in VS project and solution generator is derivative of his work.

You can still download his work, make your own generator and call it from your own Editor menu entry. In this way you can support things currently not supported e.g. the AssemblyInfo.cs file and build events.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CreepyGnome · Jul 21, 2012 at 05:52 PM 0
Share

That link is bad, and could not find it in his GitHub history, but I did find a valid link via archive.org: http://web.archive.org/web/20100110121628/http://lucasmeijer.com/posts/visualstudio-integration-for-unity25-itemtemplates/

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Visual Studio alternatives for Mac 3 Answers

Webplayer ocx src path problem 0 Answers

cannot open visual studio instead of mono developer 4 Answers

How to load VS 2013 Pro project from unity? 3 Answers

Revert script editor to Mono instead of VS? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges