GitHub Workflow Integrations: Using GitHub for Unity

Unity is a cross-platform game engine that game developers use to build scenes and attach code scripts to games. You can write the code in any editor you want, or you can use MonoDevelop, the editor that is shipped with Unity.

Integrated development environments (IDE), such as Visual Studio, have integra­tions that make writing code for your Unity game a better experience. With the full-featured experience of an IDE coupled with a clean connection back to Unity, you can be an even more effective game developer! After you create a new project in Unity, you can add the GitHub extension to your project. Unity is different from other editors. In Unity, every extension is represented as an Asset and is a part of your game, not a part of the development environment. So, when you add the GitHub extension to your Unity project, the files for that extension are a part of your game. Don’t worry; they won’t appear in your finished game, but they will help while you’re collaboratively building it!

First, open the Asset Store in Unity by choosing Window o Asset Store. Search GitHub, and you will find the GitHub for Unity asset, as shown in Figure 13-12. It is free.

Click the GitHub for Unity asset, scroll down, and click the big pink Import button. A pop-up window with all the files that will be added to your project appears, as shown in Figure 13-13. Click Import.

 

1. Using GitHub for Unity in Unity

After you install the extension, you see a new menu item in the Window menu called GitHub. If you choose GitHub, a new tab opens in Unity (see in the back­ground of Figure 13-14). Click the Initialize a git repository for this project button in the center of the new tab, and the GitHub tab updates with additional tabs related to git actions. At the top right of the GitHub tab, you can click the Sign in button to sign in to your GitHub account, shown in Figure 13-14. If you have two-factor authentication setup, you are asked for your 2fa code.

When you’re ready, you can publish your project to GitHub by clicking the Publish button at the top left of the GitHub tab. In the Publish dialog box, shown in Figure 13-15, choose which GitHub organization should own this project, put in a repository name, add a description, and choose to make it public or private.

After the project is published, you can continue to work on your project just like you would any other coding project. Items that you may find useful include

» Changes where all the recent changes are listed. You can add changes to a commit and then commit them to the branch that you’re on.

» Locks where you can lock certain files and assets so that only you can modify them. This lock becomes extremely important if you’re making changes to a game scene and you don’t want someone else to also make changes to that scene and overwrite your work.

» History is a history of all the commits for this project.

» Branches where you can see all the branches on this repo, create a new branch, and switch branches.

» Settings where you can change the remote path of your repository, change the path to git that this extension is using, and even update your git username or email. It’s recommended that you don’t modify these settings unless you know what you are doing. The extension will set these up properly for you.

» Fetch/Pull/Push/Refresh is at the top of the GitHub tab and contains four buttons that sync your GitHub repo with your local project.

» GitHub Username is at the top right of the GitHub tab where you see your username and go to your GitHub.com profile or sign out of GitHub inside of Unity.

2. Following the GitHub for Unity extension

The GitHub for Unity extension is open source, so you can track development, report issues, or even contribute to it via the GitHub repo at https://github.com/github-for-unity/Unity. It’s also important to always keep the extension up to date. A pop-up window appears in Unity whenever a new version is released, but you can also check on the Unity Asset store or directly download the latest version all from https://unity.github.com.

The team working on this extension is fairly small, so if you’re interested in con­tributing to the project, we’d highly encourage you to give it a go! You can always check out the issues on the repo on GitHub.com for ones labeled Help Wanted or Good First Issue.

Source: Guthals Sarah, Haack Phil (2019), GitHub for Dummies, Wiley.

Leave a Reply

Your email address will not be published. Required fields are marked *