Moving away from using the Unreal Engine provided rocket build can at first seem like a daunting task, but after a while you will probably find yourself asking why you didn’t switch sooner. There are a few prerequisites to being able to use the source code version, but thankfully, this article will attempt to step you through the process as gently as possible. This article will describe the process of simply getting and using the Unreal Engine source code as is, a later article will address forking the code base.

The README.md file in the source code repository has excellent instructions on this process as well.

Prerequisites

  1. A basic understanding of the GIT version control system. I will assume that you already are familiar with the basics and will simply be telling you the commands necessary.
  2. You have already completed the steps outlined by Epic, so that you CAN reach the Unreal Engine source code.
  3. A familiarity / or willingness to explore either Visual Studio (the community edition installs with Unreal Engine on Windows if you select the “Game Development with C++” workflow), or Xcode (if you are on macOS).  It is not my intention to discuss building on Linux. If you’re diligent enough to use *nix effectively, you most certainly do not need this article. Either way, you need to have one of those environments installed and ready to use.

Heads Up! Epic has started a wiki page on GIT, so check it out if you are not familiar with it.  https://wiki.unrealengine.com/Git_source_control_(Tutorial)

Step 1 – Getting The Source Code

The first step in this process is actually getting the source code. I’m counting on the fact that you have followed the steps outlined by Epic, so when you go to https://github.com/epicgames/unrealengine/, you actually see something like Figure 1.

Once you have verified that is what you see when you visit that address, you’ll see a prominent button on the righthand side near the top that reads “Clone or download”. Clicking this should show a window like it does in Figure 1. If you are using GitHub’s Desktop Client, you can simply click the “Open in Desktop” option and select where you want the source code downloaded. If you are like me, you are simply going to copy the selected path and use that a bit later.

Unreal Engine Source Code on GitHub
Figure 1 – UE Source Code on GitHub

If you are using a GIT client (like GitHub Desktop) that has started the download for you, please ignore this next bit.

So you want to brave the command line interface, awesome! You will need to navigate to the folder where you want to store the Unreal Engine source code. Your exact command line may very based on platform, so do some interpolation of what you see to match your own environment. The general gist however is that you want to tell git you want to clone the remote repository into a specific folder at your current location.

$ git clone https://github.com/epicgames/unrealengine/ UnrealEngine
Cloning into 'UnrealEngine'...
remote: Counting objects: 985780, done.
remote: Total 985780 (delta 0), reused 0 (delta 0), pack-reused 985780
Receiving objects: 100% (985780/985780), 1.08 GiB | 2.74 MiB/s, done.
Resolving deltas: 100% (653951/653951), done.
Checking out files: 100% (83402/83402), done.

The download process can take a while, so why not take this opportunity to go check if I’m streaming and tune in!

Step 2 – Getting The Extras

Just when you thought you were ready to start making awesome-ness you get hit in the face with another download. Sorry.  There are a bunch of platform specific files necessary to compile the Unreal Engine, you are going to need to download those next. Epic has been quite generous and has made a simple batch files that will kick off that process automatically.

In the folder where you chose to download the Unreal Engine source code, there will be three setup files. Each file corresponding to the build platform/operating system. If you are using Windows, double-click on that Setup.bat, and let the magic happen. If you are on macOS, look for the Setup.command, and finally if you are on *nix, the standard Setup.sh is present for you. Interesting tidbit, the macOS Setup.command actually just calls the Setup.sh, but since you can’t double-click a *.sh file to launch it by default on macOS, this is the workaround.

$ ./Setup.sh
Registering git hooks... (this will override existing ones!)
Setting up Mono
Checking dependencies (excluding Win32, Win64, Android)...
Updating dependencies: 100% (30562/30562), 5570.6/5570.6 MiB | 1.12 MiB/s, done.

 

Step 3 – The Master Branch (OPTIONAL)

UE Source Code in SourceTree
Figure 2 – Changing Branches in SourceTree

The awesome part about working with the Unreal Engine source code is that you can work with the absolute latest code straight from Epic’s own internal development team. You can even send your own Pull Requests to Epic to improve / fix issues with the engine. There is a catch however, and it is a pretty big one. The master branch at times may be buggy or not even compile at all. If you are not a seasoned developer willing to journey a sightly rougher road you probably want to skip switching to the master branch. There are less volatile branches, but that’s outside the scope of this article.

If you do end up wanting to switch the branch your working on, you can use your GIT client to select a different branch relatively easily. In Figure 2, I’m showing changing branches in Atlassian’s SourceTree. By expanding the Remotes section (your’s may differ), and drilling down further under the origin (that is a fancy way of identifying where the repository was downloaded from). I can see all the available branches. There are a lot, but there are some key ones, like release and master. Right clicking and “Checkout” on the branch I want will switch the branch over.

Your Experience May Differ

Again, if you are using a different GIT client, your experience will differ, but essentially you are looking to checkout a different branch. When you do this with a visual client, it may prompt you about the checkout becoming a ‘detached HEAD’, you can ignore that for now. Should you want to make changes to the source code, you will need to revisit this process, and look into something called a fork.

If you are using the command line, you  issue the following command in the repository folder:

$ git checkout origin/master
Checking out files: 100% (10512/10512), done.
Note: checking out 'origin/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b <new-branch-name>

HEAD is now at 3e034f4a76... Localization Automation
Setting up Mono
Checking dependencies (excluding Win32, Win64, Android)...
Updating dependencies: 100% (956/956), 1569.4/1569.4 MiB | 5.24 MiB/s, 16.4 MiB cached, done.

Notice the warning in the output about a ‘detached HEAD’, you can ignore it for now.

Step 4 – Generating Project Files

We are so close I can almost taste it. Much like the Setup files of past, now we have another pick-one set of files to run, GenerateProjectFiles. Make sure to execute the right one for your platform and it will build out the required project files to compile the Unreal Engine. This should be a relatively quick process, unlike the next step of actually building the Unreal Engine.

$ ./GenerateProjectFiles.sh

Setting up Unreal Engine 4 project files...

Setting up Mono
Generating data for project indexing... 100%
Writing project files... 100%

Step 5 – Build & Run

The only thing left is to open the project file for your platforms development environment. On Windows, as mentioned that is Visual Studio, where on macOS that is Xcode.  If you are on Windows you want to open the UE4.sln file, where as on macOS, you are looking for the UE4.xcworkspace file. Respectively double clicking on either will open the default development environment and will begin to index the project.

At this point you can either way for the indexing to complete, or you can go ahead and start the compile. It honestly, doesn’t matter at the moment if you wait for the indexing to complete. You are not using its outputs from the index, so I would recommend simply proceeding.

Windows

If using Visual Studio, you will need to select Development Editor from the solution configuration drop down, and select the Win64 platform. Right click on the UE4 target and select Build.  After the compilation has completed, you can set the startup project as UE4 and press F5.

macOS

If using Xcode, your process is similar with one extra step. Once the workspace has loaded you will need to compile the shader worker ahead of building the Unreal Engine. You do this by selecting it from the drop down title bar My Mac, and then going to the Product menu, and selecting Build. When finished, switch to UE4 for My Mac as the target. After the build is finished, you can once again go to Product and then Run.

Currently you cannot build Unreal Engine from source with JetBrains’CLion due to incorrect makefile(s) being generated by the Unreal Engine’s build tools. This is a known issue and will hopefully be fixed at some point in the future by myself or others.

Step 6 – Staying Current

With the bleeding edge version of Unreal Engine at your finger tips, the world is your playground. You want to keep it that way right?  All you need to do before you make your next build is do a pull request, which is the GIT terminology for getting the latest changes to a repository. From a GIT client, you most likely are looking for a button that says Pull on it,  clicking that should pull all updates for the current branch into your local repository. If you are using the command line interface, you will need to make sure to remember which branch you are on. In the below example, I am telling git to pull from the origin branch master any updates.

$ git pull origin master
From https://github.com/epicgames/unrealengine
* branch master -> FETCH_HEAD
Already up-to-date.

Takeaway

This is just the start of using the Unreal Engine code base. There are many different directions that you can take from here. You at the very least have the very latest which Epic has to offer, and get to play with the features they taunt the public with.

Was this article helpful?

Related Articles

Leave a Reply