Share work

if I want to create a video game with a friend of mine, as I do to “share” the unity projects to work on both simultaneously?

Thanks

what your looking for is a version control system (VCS) when it comes to unity i would recommend git, both GitHub and BitBucket are good hosts, and source tree is one of the more user friendly clients for those not familiar with bash terminal or command line.

2 Likes

You can try out Unity Collaborate. It’s simple to use, but it’s in beta and doesn’t have a lot of features.
https://unity3d.com/services/collaborate

I second what @passerbycmc said. To add to it, BitBucket provides free private hosting of repositories, while GitHub only allows public repos (so anyone can see and get access to your code) with its free accounts. Also, make sure you read up a bit on setting up a Unity-specific .gitignore file to keep unnecessary files out of the repo.

Bit of a primer on how Git works:
I have a game that consists of (let’s pretend) 2 script files. One is 10 lines long, the other is 50. When I set up the git repository for my project, I add the files to be tracked by the repo, commit the changes that I’ve made, and push those changes up to the remote branch on BitBucket.

Now my buddy wants to join in on the project, so he creates his own BitBucket account, and I invite him to the project and set up his SSH keys and whatnot. He then clones the repo from the remote to his local machine, and he now has an exact copy of the code that I pushed up previously.

While he’s been doing this, I’ve continued to work and have added 2 lines to my first script file. When I save the files and have Git check the status of the project, it looks for differences between the last version it knew about and what’s currently on my disk (called diffing). When I’m ready, I commit the changes again and push them up to the remote repo.

Buddy has been busy, too, though, and he added 5 lines to that same script file! He didn’t know I was working last night, so he commits his changes and tries pushing up to the remote. Git is smart, though, and sees that Buddy doesn’t have the latest code, so it makes him stop and pull down the latest code before it’ll let him push. When he does that, he gets a merge conflict because both of us changed the same file, on the same line, but in different ways. Since my change was pushed first, it’s Buddy’s responsibility to resolve the conflict by choosing which of the two changes to use or rewriting the line or nearby lines to accommodate both intents. Once all of the conflicts are resolved, he can then commit again and push back to the remote repo.


This seems more complicated than you may think you need, but these are the advantages to things working like this:

  • It allows you to share and collaborate on projects
  • It prevents data loss by someone working from an old copy of a file
  • It allows two people to work on the same file without losing the other’s changes
  • If your laptop melts or gets stolen, you have a backup of your project stored on the nebulous cloud
  • If you realize after a day’s work that you totally screwed something up, you can roll back to a previous version

Since I work alone, I mostly benefit from those last two points. But it’s still absolutely worth learning to use Git. Catastrophic data loss is something that only has to happen to you once to learn your lesson, but it’s better if you don’t have to suffer through that.

3 Likes