Thursday, May 26, 2016

Sharing code between Unity3D Projects

Here at Taqtile we are working on multiple Hololens projects at once and would like to create a core library for overlapping features such as an adjustable window to place or custom interactibles.

Unity3D does not natively support external folders but I found a few workarounds:

SVN Externals
This stackoverflow answer seems like the best solution but relies on SVN but unfortunately we are using Git.

Git SubTrees or SubModules
A submodule seems to be the closest thing to an SVN External but it is more of a reference to the code path at certain point in time. SubTrees are a complete copy. Neither seem ideal since we'd like to be updating the core library continuously. While you can rig both to commit and update via command prompt, most of our team uses software such as GitHub, Tortoise, and SourceTree and support seems limited or non-existent.

If you happen to have one of these solutions working on Git software with a GUI for non-technical team members I'd love to hear about it in the comments.

The solution we landed on was Symbolic Links. A symbolic link is a Windows feature to make a folder that is located in one directory to appear to be located in another. Here is a tutorial on creating Symbolic Links.

But it is as simple as running the command prompt and running the following from a relative address:
mklink /J .\Assets\TaqtileTools ..\TaqtileHoloTools

You can even make a .bat file and commit it to the relative directory so anyone setting up the project for the first time just needs to execute the bat.

Note, given that Hololens is solely a PC environment at the moment we can safely assume the entire team will be running Windows. However, Mac users could create something similar as well.