Using links (Sym Hard) to create a common folder for all Unity Projects

It all started here: http://forum.unity3d.com/threads/103967-How-to-earn-£12-000-in-one-year-from-game-development/page9

What I’m discovering is that on OSX, Symbolic Links are not recognized by Unity and they appear as simple aliases in the finder.

This means that to do this on the Mac one must use hard links, which normally only point to a file, not a directory.

There is this thread:
http://stackoverflow.com/questions/80875/

Which has code that needs compiling to do it.

There is some worry that this could muck up TimeMachine. Currently it seems that TimeMachine treats any hard links that are not its own as new files, so all linked files will be duplicated in time machine. I assume that as they are linked they will be restored properly overwriting themselves as they come down.

I am in the middle of setting up ten demo machines with our current build of the software so I am wrapped up, once I get a few moments I will fire up the Mac and tell you the exact command you need to create a symlink to a directory. Damn Mac users. :slight_smile:

(^_^)!

bookmarked !!!
thank you !!

If you don’t find a solution for a link on the mac, you could also try mounting the the directory inside of your Project.
This gave me an Idea for a quick editor scripts, will post later, I am going to bed now.

You could also use git and git submodules to version control your shared projects in one git repository and use as a submodule in another… you don’t even need pro to version control scripts without too much trouble.

rstehwien: I’ve taken a few frontal assaults on GIT and I have an account on GitHub, but I have yet to figure out how to integrate this into a Unity project.

You can use git locally… one of the advantages of git is you don’t need a server like you do with subverison. GitHub (where I have many projects myself) is useful for sharing projects with the public (free) or a team (pay… unless you want it open source). I use git on my local machine for projects that will never be put on a server… just drives me crazy to not use source code control.

Here is a good book:

Setup instructions:

Section on submodules:

If I have some time later… I’ll get some unity specific instructions ready for using git. All my unity projects have been throw away… but I’m rapidly approaching real projects that will require the use of git. I have used git for my professional work outside of unity so I know it can work.

rstehwien: THANKS!

I’ll follow these links and report back.

I have remembered this:

… where version control is mentioned, but I have no clue whether this could be made to work between projects.

I haven’t had time to writeup instructions but here are two github projects I found (by the same person but there were others) that have instructions for using git submodules:

https://github.com/MrJoy/UnityGUIExtensions
https://github.com/MrJoy/UnityREPL

Basically you do the following (the path to the module will vary and may even be local)

GIT SETUP IN A UNITY-PRO PROJECT THAT IS NOT VERSIONED WITH GIT

You must have External Version Control enabled to use these instructions. If not, please download the .unitypackage and use that.

cd myproject/
mkdir -p Assets/Editor/
git clone git://github.com/MrJoy/UnityREPL.git Assets/Editor/UnityREPL
git clone git://github.com/MrJoy/UnityGUIExtensions.git Assets/UnityGUIExtensions

By setting up this way, you can track updates using “git pull”.

GIT SETUP IN A UNITY-PRO PROJECT VERSIONED WITH GIT

You must have External Version Control enabled to use these instructions. If not, please download the .unitypackage and use that.

cd myproject/
mkdir -p Assets/Editor
git submodule add git://github.com/MrJoy/UnityREPL.git Assets/Editor/UnityREPL
git submodule add git://github.com/MrJoy/UnityGUIExtensions.git Assets/UnityGUIExtensions
git submodule init
git submodule update

LINKS
Some links on setting up git in general.

http://unity3d.com/support/documentation/Manual/ExternalVersionControlSystemSupport.html
http://www.chrisdanielson.com/2011/06/04/unity3d-projects-version-control-git/
http://raypendergraph.wikidot.com/using-git-with-unity3d
http://forum.unity3d.com/threads/69609-Source-Control-w-Free-Unity-ignore-files-(Git-SVN-CVS)
http://answers.unity3d.com/questions/topics/git.html

http://book.git-scm.com/

Was asked to follow up on this. I had forgotten that Unity on Mac OS X for whatever reason won’t see symlinks to directories. You have to create hardlinks to directories instead. Mac OS X won’t let you do that by default, even though the underlying DFS supports it. It’s how Time Machine works.

I followed this guide from 2008 on how to put a hard link to a directory on your machine: http://osxbook.com/blog/2008/11/09/hfsdebug-40-and-new-hfs-features/

Hard links are not for the faint of heart and can tie your file system in knots if you aren’t used to them.

If you don’t want to use hard links, try instead a two way rsync or even Unison Unison File Synchronizer which will do it for you.

Thanks, JustinLloyd!

We really appreciate the professional help.

The above link clearly shows the only way to create a hard link to a directory on the Mac is to write some custom code and build it. It specifically has numerous scary warnings about trashing your file system if you use this. No thanks!

I can confirm that Unity 2.4 refuses to follow symlinks to directories on Mac OS X. It works fine on Windows machines. We have shared Editor, Plugins, and even various project-level Resources and Scripts directories. Works PERFECTLY on Windows (which is hard to make symlinks on).

I will make some hard-links now, but this is hard and potentially dangerous. How do I report a bug on this and request it get addressed?

Christopher
DreamQuest Software

Open Unity
Select Help menu
Select Report Bug

Yeah, the Mac OS X solution is less than ideal, but it was the only way to fix it. I assume you mean 3.4 rather than 2.4. :slight_smile: You can of course get around all of this nonsense by using version control on your source code, but it shouldn’t have to be that way. :frowning:

What he said.

TBH, I’m waiting to see how version control works in 3.5. This may make things easier. Not sure why Unity Mac doesn’t support aliases (soft link) by default, as they are a system feature. Could be a base architecture issue. I know some of the features I’d like to see (nested prefabs for instance) are on the road map, bit require fundamental changes in the architecture of the editor. Perhaps windows links work as the windows editor is relatively new compared with the Mac? Report it. Let’s see if we can get some mileage out of it.

is it still the same on Mac OS? how can i use symlinks on Mac?

On a Mac use :

ln -s [source] [target]

So let’s say I have a directory of shared assets located at:
/Users/ZG/Projects/Unity/SharedAssets

And I wanted a symbolic link to that in the folder:
/Users/ZG/Projects/Unity/AwesomeGame/assets

I would type:

ln -s /Users/ZG/Projects/Unity/SharedAssets /Users/ZG/Projects/Unity/AwesomeGame/assets/SharedAssets

Important: It will create the link “SharedAssets” in that directory, so if you already have a folder or file with that name, it will be overwritten.

Unity will throw a notice in the console saying essentially that you should be careful doing this. Which is good advice, if you delete/change any of the files in there, it will impact all your projects using that alias. (since there is only one set of files)

Be aware that Unity’s support for symlinks has fluctuated somewhat due to concerns that you could really mess things up if you are not careful, especially on the mac.

As of 4.2, symlinks are now supported on both the Mac and Windows platforms:

http://unity3d.com/unity/whats-new/unity-4.2

I just finished get this set up on my Mac; now, whenever Unity regains focus, it reimports every asset in the symlinked directories. The project is still small – so it only takes 20 seconds – but given how I bounce back and forth between Mono and Unity, even 20 seconds is intolerable. The assets are not changing; there are no “circular” symlinks; this only happens on Mac; Pcs are fine. Please help.

Steve

Edit: BTW, I just tried something; instead of linking to many (10 or so) directories, I just symlinked to the “parent-most” directory and the “always reimporting problem” went away. Although this is good news, it is NOT a solution. It is just a clue into how fix the bug – please fix the bug. I should have the option of “symlinking”’ any number of directories – not just one.

Edit2: I am now going to experiment with 2 symlinks and see what happens.

Edit3: The problem occurs if I have 2 or more symlinked directories – regardless of how many or few files are in those directories

If you believe this is a bug, then please submit a bug report.

I do not use, nor fully understand all of the ramifications of, sym-links. These are not limited to setting up the symlinks, circular links, confusing backup engines and potentially corrupting multiple projects at once by updating the shared folder(s).