Github For Unity



The open source GitHub for Unity editor extension, which brings Git into Unity with an integrated sign-in experience for GitHub users, is out of beta and available for download.

Unity is the popular multi-platform game engine used to develop and deploy two- and three-dimensional games for a wide range of platforms and devices. The GitHub for Unity extension provides a better way to integrate Git and GitHub into Unity workflows, even when a developer is working with large binary files.

  • The reason why you need this, is because the 2D-Extras package wants to be downloaded via the Unity Package Manager, which in this case, uses GitHub to store the source code and hence git to download the data. The Package Manager needs to know how to use git on your computer because it is not bundles with Unity.
  • GitHub Campus Expert. Grow your leadership skills. Build the tech community at your school with training and support from GitHub. Campus Experts learn public speaking, technical writing, community leadership, and software development skills that will help you improve your campus.
  • OpenIAB plugin enables Unity developers to reduce integration and maintenance time. The plugin uses one common interface for 3 mobile platforms: Android, iOS and Windows Phone 8. It’s based on OpenIAB library developed by One Platform Foundation team.

While the extension is called GitHub for Unity, it can be used with other Git servers such as on-premises installations. When used with Unity, the extension integrates Git and GitHub directly into the Unity Editor, so developers can configure, collaborate, and manage a Git project in a dedicated window. The extension also includes Git LFS v2.0 support to store large binary assets. The LFS (large file storage) client means you can store large binaries in separate storage, and still work with them in the Git repo. This option of storing large asset files outside your repository (but still on GitHub.com servers) means the repository becomes smaller, making cloning and fetching faster. The option also makes versioning possible.

Compact and simple easing functions for Unity. GitHub Gist: instantly share code, notes, and snippets.

File locking is another feature of the extension, meaning developers working in teams can lock files they are updating to prevent other users from updating them at the same time. Concurrent edits in Git repositories lead to merge conflicts, which are very difficult to resolve in large binary files.

The newly released version has some improvements to the beta. The file locking management is now a top-level view within the GitHub window, so can be used to lock or unlock multiple files.

Diffing support has also been added so developers can use their favorite diffing program to visualize changes to files directly from the “Changes” view in the GitHub window. Other improvements include improved Git and Git LFS support for Mac, and a Git action bar for essential operations.

More Information

Related Articles

Visual Studio Improves Gaming Tools For Unity

To be informed about new articles on I Programmer, sign up for our weekly newsletter,subscribe to the RSS feed and follow us on Twitter,Facebook or Linkedin.

Drone Software Defies Imagination
18/04/2021

The Guinness World Record for the number of UAVs - Unmanned Aerial Vehicles or drones - airborne simultaneously has been broken again. Watch the spectacle and consider the programming effort that must [ ... ]


Scott Aaronson Winner of 2020 ACM Prize In Computing
14/04/2021

Scott Aaronson is the recipient of the 2020 ACM Prize in Computing for his 'groundbreaking contributions to quantum computing.' Aaronson, who is Professor of Computer Science at the University of [ ... ]


More News


Comments


For

or email your comment to: comments@i-programmer.info

Unity is awesome. Git isawesome. Wouldn’t it be nice if they got along?

By default, the Unity editor does not work well with Git. To name a fewproblems:

  • Noise: The editor manages hundreds of temporary files. Merely opening orclosing the editor will create, delete, or modify some of these files.Additionally, since it’s possible to develop on and build for multipleplatforms, there are many more extraneous files than you might expect to findon, say, a Rails project.
  • Broken object references: The editor keeps track of objects with randomlygenerated GUIDs. If these GUIDs are not committed to Git properly (i.e., via.meta files), the project may break when you, for example, switch branches.The more you rely on the editor, the more common and potentially catastrophicthese errors are.
  • Unresolvable merge conflicts: Depending on your settings, the editor willsave some or all of your files in binary format. If you and a team memberhappen to edit the same file independently – a common scenario if you use theUnity editor heavily – you will not be able to resolve the merge conflictwith Git, and will have to use special tools.
  • Large files: A typical Unity project requires a number of large binaryassets for 3D models, sounds, images, fonts, etc., which can significantlyslow down your Git workflow and waste storage space.
Github

The solution is straightforward:

  1. Add Unity-specific .gitignore settings
  2. Configure Unity for version control
  3. Use Git Large File Storage

1. Add Unity-specific .gitignore Settings

We recommend GitHub’s Unity .gitignore template.

Github For Unity Reddit

In addition, depending on the platforms you intend to use for development, youshould gitignore common files for macOS and/orWindows.

2. Configure Unity For Version Control

With your project open in the Unity editor:

  • Open the editor settings window.
    • Edit > Project Settings > Editor
  • Make .meta files visible to avoid broken object references.
    • Version Control / Mode: “Visible Meta Files”
  • Use plain text serialization to avoid unresolvable merge conflicts.
    • Asset Serialization / Mode: “Force Text”
  • Save your changes.
    • File > Save Project

This will affect the following lines in your editor settings file:

  • ProjectSettings/EditorSettings.asset
    • m_ExternalVersionControlSupport: Visible Meta Files
    • m_SerializationMode: 2
  • If you’re curious, you can read more about Unity’s YAML scene formathere.

3. Use Git Large File Storage

Git Large File Storage (LFS) uses Gitattributes totrack large files with Git, while keeping them out of your actual repository.Note that this will only work if you use GitHub or aserver that supports the Git LFSAPI.

To set it up, download and install the Git LFS command line extension asdocumented on the Git LFS site.

You can manually track the file types that you’d like Git LFS to manage, asdescribed in the Git LFS docs. However, given the numerous file types that Unitysupports, you are likely to miss a few.

GithubGithub For Unity

Instead, feel free to use this sample .gitattributes file, whichcomprehensively accounts for all the file types that Unity currently supports(either natively or via conversion):

A Bonus For GitHub Users: Automatically Collapse Generated File Diffs

If you use GitHub to review diffs (ex., as part of a pull requestworkflow), you’ll noticethat changes in Unity-generated YAML files are usually not actionable. You canreduce the clutter they introduce, while preserving the ability to review themas needed, by automatically collapsing thediffs on GitHub.

To do so, just append this to your .gitattributes file:

You can read more about this featurehere.

You should now be able to use Git to version control a Unity project as younormally would:

  • Any changes detected by Git will be legitimate, not noise generated by theeditor.
  • You will be able to commit your changes to your repo confidently, withoutfearing that the project will suddenly break when a team member tries to fetchit or you switch branches.
  • Your large binary files can be tracked without slowing down or cluttering yourrepository.
  • Changes to files generated by Unity (such as Scene files) will have diffs thatcan be inspected normally, and merge conflicts can (at least in theory) beresolved manually. Although…

Actually, About Those Merge Conflicts…

Unity Build Github

Manually resolving merge conflicts between Unity-generated YAML files is verydifficult and error-prone. If you followed the steps above and you’re usingUnity 5 or later, you can use the editor’s SmartMerge (a.k.a, “Unity YAMLMerge”). There are also various merge tools on the Unity AssetStore.

As a developer, though, I find these solutions somewhat unsatisfying. Theunderlying problem is not that there is a merge conflict, per se, but that atool (the Unity editor) is translating our commands and our knowledge into alanguage (the Unity YAML format) that is difficult to understand, and indeedthat was not really meant to be manipulated directly.

Github For Unity Command Line

Fortunately, a code-centric approach to Unity development (ex., viaZenject) can minimize these kinds ofproblems, while also supporting numerous software development best practicesthat are often lacking in Unity development.