using a standard code base for many projects

hello

in C++ you can have source code base or libs (*.a files or *.lib) in one (svn) controlled directory, and have many projects use that base. This way, there’s only one “copy” of the base code for all to use projects. Also, any updates and bug fixes that happen because of 1 project is now available to all projects.

Is there a way for this to happen with C# and unity? Can unity get code from more than the current project’s assets dir?

The reason C++ use pre-compiled libs is so the compiler can optimize the final output. Mono doesn’t use precompiled the same way, instead it uses fully compiled dll’s. Keep in mind that since JIT optimizes the result runtime this mean that the end result is equally optimized. So you just build a mono dll and put it in your assets folder, that way you’ll have full access to everything inside them. :slight_smile:

Cheers,
UnLogick

I don’t think he’s after optimisation here, I think it’s about workflow. What he’s talking about is having shared code external to the project, shared with other projects, so that when it’s updated for one project others automatically benefit from it.

A DLL is one way to do that, but workflow-wise it’s a bit clunky because every update to the shared code by anyone would require manual re-integration by everyone else. No biggie for small projects, but in some cases it could be a pain.

As far as I know, Unity has no built in way to reference an external project/codebase. My only experience with shared code involved using the same Unity project (in an Asset Server) to combine multiple “sub-projects”. This mostly works pretty well, but becomes painful itself if the different “sub-projects” require different build settings. For what we were doing that’s not an issue, but it’s something to be considered.

yeah, workflow was what i was getting at. Thanks for your suggestions. I’ll bring them up to my other team members and see what they think. I just wish we could access different code directories… :confused:

a co-worker found this approach on unity answers:

I handle this similar to the solution above with a symbolic link - my common libraries are on a github repo (the symlink is to the working copy from that repo). That way, I don’t have to keep replacing the common libraries in my individual projects.

I think the best way to do this with unity is through linking/version control.

what i ended up doign was this

  1. separate code into groups, and then placed in their own directory on svn. ex: all mesh related/connected code went into a mesh folder, all networking code went into the networking folder, etc
  2. in my unity project, i create an empty scripts folder
  3. on svn, i get the code groups that are useful for the project, and check out the whole folder. the code will stay in its folder on the local drive within the scripts folder
  4. any game specific code will go into its own folder within the scripts folder. i then check that into svn.

so now the scripts folder has nothing but folders within it, and within those folders is all the source code that’s under version control. This way if i want to use the networking code in a 2nd project, i can easily check it out in the assets/scripts folder in project 2…yet i wont have anything else from project 1. Also, all the new code i add for project 2 can be updated in project 1 without changing anything else in project 1…AND i wont get weird conflicts or having svn think that some files are missing from the 2nd project.

so far, this seems to work, but i wont see any REAL issues until i use this system for a lil while.