3

I am working on large projects that have Common asset in separate git repository. How we setup the projects in brief is this:

/ # Main unity project
/ext/Common # Common source unity project (checked in using either git subtree or submodule)

Common contains Assets folder as any unity project would

/ext/Common/Assets is symbolic linked to /Assets/Externals/Common

We have git post-checkout hook written that checks if /Assets/Externals/ link exists for each directory under /ext/ that contains Assets subfolder.

This works okyish but there are some dilemmas:
A) We use different windows versions and OSX in our team. We need cross platform way to write the post-checkout script. Hence dependency to python.
B) Git post-checkout hook does not trigger in after git pull which would be optimal.
C) Git post-checkout hook need to be written in the repository only way I could get this happen was to push is in some location in the repository and modify git config git-hook path.

I have considered replacing the git post-checkout hook with Unity AssetPostprocess::OnPreprocessAsset. However the caveat with this is that it wont trigger on fresh checkout as project scripts have not compiled and as there are scripts missing in Unity as the symbolic links have not been formed... Not a good thing.

What alternatives can you think of to over come A), B), C) problems? Are there better git hooks? Do you have idea how avoid this mess with multiple projects?

2 Answers 2

2

we have used git submodules in a similar way, but not using symlinks. The git submodule was checked out into <Unity project>/Assets/Common. No post-checkout hooks, and no cross-platform issues, but some members (mostly designers) of our team had trouble getting the latest version of submodules without explicitly doing a submodule update from the command line. This proved to be so frustrating for them that we decided not to use it anymore (even though I liked it).

2
  • Considered that but in our case the Common git project includes some scripts etc files that we dont want in the main project Assets folder. I suspect that in your case you only pushed unity assets into the Common repository? Commented Sep 21, 2018 at 10:16
  • 1
    No it was everything that was common to our projects. So scripts, fonts, textures and prefabs, and whatever else was useful not to have to change in the other projects when it was changed in one. The common repo was not a Unity project in itself. If you don't use the scripts (or other assets, for that matter) you don't want, they won't actually end up in the built project. Commented Sep 21, 2018 at 12:52
0

I can't add a comment on @frankhermes' post.

Old thread I know, but it may help others.

You can easily allow designers to get latest submodule version by creating a MenuItem for Unity with editor scripts that either calls cmd with a fixed command through Process API, or integrate a .net git library that allows you to do the same.

Used the same concept for generating versioned packages in Unity when I was finished making changes for a newer version that updated package.json and created the archive I was supposed to upload to our internal npm server. Obviously custom packages might not have been a consideration back in 2018, but at the very least, Process API would still be accessible through editor scripts.

Not the answer you're looking for? Browse other questions tagged or ask your own question.