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

How do you address code sharing across your unity projects?

Discussion in 'Editor & General Support' started by ivaylo5ev, Oct 12, 2019.

?

Which code-sharing approach are you mostly using in Unity

  1. Unity Packages (.unitypackage files)

    50.0%
  2. .NET Class Libraries (.dll files which I copy to the Assets folder of my projects)

    50.0%
  3. Assembly Definitions (.asmdef files), along with the scripts. I copy them across projects

    25.0%
  4. I am using NuGet or Paket to install nuget packages

    25.0%
  5. other (add a reply, I'd be intereted to know of other ways)

    75.0%
Multiple votes are allowed.
  1. ivaylo5ev

    ivaylo5ev

    Joined:
    Sep 2, 2016
    Posts:
    10
    Hello,

    I am wondering how most of you approach sharing common functionality across your unity projects?
    Do you develop .NET class libraries along the way?
    If so, how do you get to use the UnityEngine dlls as part of your library?
    For example, do you keep a local copy of the dll which you reference by filesystem location and etc (as I was doing for some time). What best practices would you recommend when you want to switch to a newer Unity version?
    Is there a way to enable library sharing with the new assembly definitions / (.asmdef) and how?

    I have personally used class libraries successfully for a couple of years now. However,
    I ran recently into an issue (see here: https://answers.unity.com/questions/1671358/issues-with-unityengineui-when-referenced-in-a-cla.html), and I am starting to wonder whether the class library approach is still suitable for modern unity development. That is why I am creating a poll in order to get a better picture on the matter.

    I'd love to see you share your thoughts on the topic.
     
    Last edited: Oct 12, 2019
  2. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    All of them - except NuGet - but instead UPM via package manager.
     
    ivaylo5ev likes this.
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
  4. ivaylo5ev

    ivaylo5ev

    Joined:
    Sep 2, 2016
    Posts:
    10
    @Peter77, Nice bringing the git submodules on the table :) Besides the submodule do you also do any work in regards to linking the submodule contents to the unity project (like symlinking or autmated copying). Or maybe you checkout the submodule in the appropriate location within the Assets folder?
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
    This. I checkout the submodule in the appropriate location within the Assets folder.
     
    MNNoxMortem and ivaylo5ev like this.