- Home /
Sharing scripts and prefabs between Unity projects
We are using Kiln (similar to Git) with External Version Control and Unity Pro. We have several shared components that we want shared across several of our Unity projects. We would like to be able to edit the shared components in any of the projects and have it update in all of our games.
Examples:
Prefabs\Card.prefab
Resources\Cards.png
Scripts\Messenger.cs
As suggested in other threads, I have already tried:
Yes, we have external version control turned on and know what files go where. No issues with that.
Kiln does not allow a shared subdirectory inside one project to be inside another (at least not that I can figure out).
Symlinks seemed a logical choice, but MonoDevelop on Windows does not seem to open symlinked files (Visual Studio and Unity handle them fine). I have also seen posts about Unity for Mac having issues with symlinks and our current continuous integration Mac build server seems to be freaking about the links.
If we share prefabs, etc. will Unity allow the sharing of the GUIDs, etc. in the .Meta files or will we run into issues if Developer A edits the shared files via Project A and later Developer B edits those SAME shared files via Project B?
Thanks, Christopher
Answer by spadesmaster · Mar 02, 2012 at 07:38 PM
Since no one ever answered my question, I will share what we are doing. We are using symlinked shared folders to share assets between projects on Windows. We eventually found a way to hard link directories on the Mac which worked as Unity 3.5 STILL does not honor symbolic directory links on Mac.
There is also a helpful trick for automating the #define settings on a per-project basis as well that we found useful and I will try to writeup when I get a chance.
I'm unsure how to message people using the unity system, but I hope this message will reach you. Have you written up the trick for automating #defines across multiple projects and scripts? What was the means by which you hard linked directories on mac and would it be possible for you to explain how you symlinked your folders?
We 'precompile' our projects to add the #defines at the top of our shared files that require it. To switch projects we first run our Perl script. I will attach the Perl script we use. It ain't pretty, but it works well for us. Renamed from .pl to .txt so it would allow the upload. Hope it helps!
Answer by spadesmaster · Sep 25, 2012 at 04:45 AM
We 'precompile' our projects to add the #defines at the top of our shared files that require it. To switch projects we first run our Perl script. I will attach the Perl script we use. It ain't pretty, but it works well for us. Renamed from .pl to .txt so it would allow the upload. Hope it helps!