-
Notifications
You must be signed in to change notification settings - Fork 0
DevelopmentEnvironment
The following tools are required for this project:
- Unity Editor
- C# code editor. Better to use an IDE:
- Rider (recommended, has great integration with Unity, easy to debug with, free student license available)
- Visual Studio (also has integration with Unity, not as fully-featured as Rider)
- Git. You can use any git-compatible software, like GitHub's own GitHub Desktop (recommend to using this one).
If you already know what tools you are going to use, just skip to the Project setup section, to setup the project on your machine correctly.
While you can use any tools you want for this project, here are the recommendations on what tools work the best.
You can simply download the latest version of Unity here, but it might be more convenient to use Unity Hub, which can manage downloading, installing and getting updates without additional hassle of using installers.
However you decide to install Unity, make sure that all of your team members are using the same version of Unity, because opening a project in an older version of Unity that was last opened in a newer version of Unity might be impossible, it might also complicate merges.
Download and install Unity Hub. This application lets you easily download, install and update Unity and manage multiple versions of it at the same time.
After downloading Unity Hub, open it, login to your Unity account (create one if you don't have it), go to Installs -> Official Releases and download the latest official release of Unity.
It is recommended to use Rider rather than Visual Studio, because it has a better Unity integration. More specifically, attaching to Unity for debugging and still being able to edit code. With Visual Studio, attaching to Unity takes a few more seconds (in Rider it happens almost instantly) and you cannot edit the code while it is attached. Detaching also takes a few seconds. In addition, there's extra buttons to run, pause and stop the game directly in Rider, rather than doing that in Unity. Rider also has an easier to use debugger and is a great IDE in general.
If you don't already have one, you can get a FREE student's license for Rider here. This will give you a license for all the great JetBrains products for one year, which you will be able to renew when it expires.
You can download Rider directly or use JetBrains Toolbox app, which will make installing and updating Rider much easier.
Download and install GitHub Desktop. It's a great, easy to use and simple app for committing, changing branches, pulling, pushing, creating pull requests and so on..
The Unity project has a GitHub plugin installed. It supports creating commits, pushing, pulling, creating branches and most importantly file locks, so only one team member could edit a specific file at the same time. It's really only good with file locking, everything else is just meh with it.
Clone this repository using your Git client. With GitHub Desktop you can do this by selecting one from the list of Your repositories or pressing the Clone a repository from the internet... button and following the instructions.
After cloning is done, open the Unity project, located at Tree/ directory. This will create the necessary files for the Unity and C# project. Some errors might show up in console when first opening the project. Just clear the console, if all errors go away then you can ignore them. You can open the GitHub plugin's window by clicking Window -> GitHub.
You can now open the solution (Tree/Tree.sln) in your IDE.
Rider only: After Unity has setup the project, open it in Rider, by opening the solution file Tree/Tree.sln. This will setup the project for use with Rider and also make sure to set it as the default code editor for Unity.
This is very important:
After the project has been opened in Unity and the GitHub plugin has been completely setup, the Unity merge tool must be configured to be able to merge *.unity (scenes files) and *.prefab files correctly. Any default merging tools will not be able to merge these files correctly and will corrupt them.
In order to do that, you have to edit the .git/config file (it's located in the repository's root directory, where you cloned the project into). The .git/ directory is usually hidden, so enable showing of hidden files if you don't see it. Then append these lines to the end of the file, changing the _UNITY_INSTALL_DIR_ to the full path to the Unity directory:
[merge]
tool = unityyamlmerge
[mergetool "unityyamlmerge"]
trustExitCode = false
cmd = '_UNITY_INSTALL_DIR_\\Editor\\Data\\Tools\\UnityYAMLMerge.exe' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"The file might already have a similar entry like this one below:
[merge "unityyamlmerge"]
name = Unity SmartMerge (UnityYamlMerge)
driver = '_UNITY_INSTALL_DIR_\\Editor\\Data\\Tools\\UnityYAMLMerge.exe' merge -h -p --force %O %B %A %A
recursive = binaryLeave this entry as-is, do not delete it.
The full file in the end might look like this (do not copy this one, it's only for reference):
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/MKlegoman357/UnityGitTest.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[lfs "https://github.com/MKlegoman357/UnityGitTest.git/info/lfs"]
access = basic
[gui]
wmstate = normal
geometry = 1488x788+646+394 175 196
[merge "unityyamlmerge"]
name = Unity SmartMerge (UnityYamlMerge)
driver = 'C:\\Program Files\\Unity\\Hub\\Editor\\2018.3.6f1\\Editor\\Data\\Tools\\UnityYAMLMerge.exe' merge -h -p --force %O %B %A %A
recursive = binary
[merge]
tool = unityyamlmerge
[mergetool "unityyamlmerge"]
trustExitCode = false
cmd = 'C:\\Program Files\\Unity\\Hub\\Editor\\2018.3.6f1\\Editor\\Data\\Tools\\UnityYAMLMerge.exe' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"You will have to also download any merge conflict resolving diff tool, because the Unity Smart Merge Tool isn't smart enough to provide any manual conflict resolving capabilities. It is recommend to use the Diff Merge tool. It's lightweight and it works with Git out of the box without any additional setup required.
If you want to use another merge conflict resolving diff tool that is compatible with Git, you will have to configure it with your Git installation manually.
You can find more information about setting up the Unity Smart Merge Tool here.
Whenever there is a merge conflict related to a *.unity or *.prefab file, you should open the project in a Git command-line and run the command git mergetool. This will run the Unity Smart Merge Tool, automatically merging everything it can. If there's a conflict it cannot merge, it will open the configured diff tool and you will have to manually and very carefully resolve the conflicts yourself.
Unity merge tool will not automatically delete any *.unity.orig and *.prefab.orig files, so you should discard and delete them together with any accompanying *.unity.orig.meta and *.prefab.orig.meta files.
If you are using GitHub Desktop, upon stumbling on a merge conflict you will be given a choice to resolve it using external tools. Choose the command-line option:

After the terminal opens up, run the git mergetool command to merge the files:

After that, you can choose to commit the merge changes and discard the files mentioned in Using Unity Smart Merge Tool section.