GitHub Repository

All the ootii assets are stored in a private GitHub repository that is only accessible to developers.

When invited, you can get to the repository from here.

https://github.com/Tryz/UnityAssets

 

First, create a GitHub account: https://github.com/

Next, download GitHub Desktop: https://desktop.github.com/

Once you create your account, send tim@ootii.com your GitHub user name.

 

GitHub Site

When I add you as a collaborator, you’ll be able to go to the UnityAssets repository and it should look like this:

What you’re looking at are the Unity projects that get submitted for each asset as well as an “_AssetMaster” project. The _AssetMaster (AM) project includes all of the assets. This is where I do all of my development.

Once we’re done making changes, I use WinMerge to move the changes to the individual asset projects as need. Those individual projects are what I push to Unity.

 

GitHub Branches

GitHub is a bit different than Perforce and other source control solutions. While we can deal with individual files, we’re really working in a branch.

Think of a branch as a snapshot of the main project that we can modify without affecting the main code line (called the master branch).  Then, when we’re done with the changes we can merge our branch changes into the master branch.

 

GitHub Desktop

GitHub Desktop makes it really easy to pull from the repository, make changes, and push those changes back up to the repository. Basically, we’ll tell GitHub what repository we want to clone and where.

When we clone a repository, we’re just making a copy of a branch that is connected to the real repository up on GitHub.com.

So, we’ll do the following:

1. Open up GitHub Desktop.

2. From the ‘File’ menu, press ‘Clone repository…’

You’ll probably have to log-in the first time. Once you login with your GitHub account, you’ll search for a repository. You’ll see it’s called ‘Tryz/UnityAssets‘.

Then, you’ll enter a local path where you’ll work from. I put mine here:

D:\Development\com\ootii\Sales\UnityAssets

Of course this is relative to my computer. So, put your local path anywhere you want.

 

3. The next thing we do is specify the branch we are working on. In this case, I’m going to work out of a branch I created called ‘Assembly-Definitions’.

If we wanted to, we could change the local version by changing the ‘Current branch’.

 

4. Once you do that, you’ll want to press the ‘Fetch origin’ button that’s at the top right. That will pull all the contents from the web and place it in your local path.

The first time you do this, it can take a while.

When you’re done, you’ll have a folder structure similar to the web page above.

4. With that, you can now open the individual projects with Unity. I’m currently building them all with Unity 2017.4.1f1, but I will be dropping the asset-based projects down to Unity 5.6.0 before I push them to the asset store.

The _AssetMaster project will typically be the latest version of Unity.

 

GitHub Workflow

Now that we have the code base on our computer, we can make changes. GitHub Desktop works by watching file changes, additions, and deletions and batching them up.

For example, lets say I want to change the ReflectionHelper.cs file. I would open the _AssetMaster project, open the file, and make the change. Then, when I go to GitHub Desktop, the change will be listed in the ‘Changes’ tab like this:

You’ll continue to make changes and GitHub Desktop will continue to track them. Unlike other source control solutions, you don’t typically ‘commit’ every file change every day. Instead, it’s more like you’re working on a feature or solution and you commit when you’re done.

 

Committing Changes

Let’s say this is the only change you want to do and you’re done. We can commit that change from your local path to the branch you’re working in by pressing the blue ‘Commit to …’ button under the change list.

You’ll have to enter a title and some notes first.

That will wrap up the changes and put them in the ‘History’ tab like this:

You’ll notice that your ‘Changes’ tab is now clear.

 

Pushing to the Server

Finally, when you’re ready to send it to the server press the ‘Push origin’ button. That will wrap up all the things in the History that haven’t been sent and send them.

 

Pulling from the Server

Since we’re both working at the same time, You’ll want to check if there’s changes for you to pull down before you start working. So when you open GitHub Desktop, press the ‘Pull Origin’ button at the top right.

If there’s stuff for you to pull down, you’ll see a small number and ‘down’ arrow. Press the button again and it will pull changes from the server to your local path.

 

Merging Branches

When we’re done with a major feature, we’ll want to merge our branch into the master. Then, I typically delete the working branch and create a new one.

I’ll do all this. So, don’t sweat that.

 

Notes

1. Since GitHub just pulls and pushes file changes, be careful what you put into your folder structure.

For example, I were to build a demo and put the exe in my “UnityAssets” folder, that would become part of GitHub. We don’t want to bloat the server with things like that. So, make sure any extra stuff that really isn’t important is place somewhere else.

 

 

 

 

 

Leave a Reply