Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Visual Studio Project Management

Discussion in 'Scripting' started by ccjay, Jan 31, 2018.

  1. ccjay

    ccjay

    Joined:
    Mar 24, 2014
    Posts:
    20
    How does Unity decide when to create a new project under the solutions umbrella.

    I have my directories and namespaces setup as:
    • Assets
      • Editor
      • MainGame
        • Graphics
        • Scripts
        • ect
      • Plugins

    When I pop into Visual studio, my solution has three projects:

    • Solution
      • Game
        • Assets
          • Editor
          • MainGame
          • Plugins
      • Game.Editor.Plugins
        • Assets
          • MainGame
          • Plugins
      • Game.Plugins
        • Assets
          • MainGame
          • Plugins


    There is a ton of redundancy, and artificial dependencies across projects where I don't really think there should be. I am perfectly fine with all my code sitting under a single Project.Is there a best practices here that I am fighting against? Should Editor / Game logic be in separate projects explicitly?

    I can of course close the other 2 projects and truck away, but if I ever reopen Visual studio those projects are recreated by Unity.

    I fully admit it could be related to some messy namespacing.. I have bought a few frameworks off the asset store and it's been a little annoying to pull them into my project.
     
  2. ccjay

    ccjay

    Joined:
    Mar 24, 2014
    Posts:
    20
    For anyone who comes across this thread. It seems the Visual Studio projects that get generated are on a 1:1 to how many sub-folders you have under the Assets Hierarchy.

    Not sure if there is a way to exclude or manage this with more detail.
     
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,514
    Note, it's not 1:1 to how many sub-folders you have under the Assets Hierarchy. I have 20 folders under Assets, and only 4 projects in Visual Studio:


    If you read the names of the projects, they'll sort of describe what they are for.

    Mine are:
    UnityProject - the game code
    UnityProject.Editor - the editor code for my game... code found under a folder named 'Editor'
    UnityProject.Editor.Plugins - any code inside a folder named 'Plugins' that is under a folder named 'Editor'
    UnityProject.Plugins - any code inside a folder named 'Plugins'

    The projects correspond to the various special folders that unity has:
    https://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html

    For the folders relating to compilation/code, they control the order, and can be seen as independent projects due to that order of compilation.
     
    TaleOf4Gamers likes this.
  4. Xype

    Xype

    Joined:
    Apr 10, 2017
    Posts:
    339
    Well said lordofduct, VS just makes separate solutions for the game, editor plugins and project plugins just provide tools they aren't needed in the final solution you send to your gamers, so VS just sorts it out, yes Microsoft actually did a smart thing. Otherwise best thing ya can do, chunk VS lol. Grab yourself Rider and ReSharper, find out what real profiling and debugging tools can do for you.