[TIP] Generating Build Numbers for your game

When i am compiling my projects i would like to know how many times i compiled my project. So i made that kind of functionality for one of our project and thought i’ll share it with you guys. 🙂

First of all you need a header file to track the game build changes. Here is a screenshot of my header file from our project. Its called GameVersion.h



Next i created a simple text file called GAME_BUILD.txt and it contained only the build number. Nothing else. This file was located in my Project Source/Project Name folder. (for example: D:\Unreal Projects\MyProject\Source\MyProjectFolder). Here is a screenshot of that file.



Now comes the real part. Go to your Project Folder/Source and open up MyProject.Target.cs file. Here in this screenshot you can see how i modified the main function. Modify it like that and make sure to point to your GameVersion.h and GAME_BUILD.txt files correctly.

Target.cs file

Target.cs file

Now every time you compile your project it will automatically increment your build number. To access this build number simply include GameVersion.h file  and get GAME_BUILD_NUMBER. 🙂

Compile Output

Compile Output

Hope this tip was useful. 🙂

NOTE: The only downside to this method is it will always increment the build number even if your project fails to build.


About Satheesh (ryanjon2040)

Genuine Unreal Engine user

Posted on July 31, 2015, in Unreal Engine 4 and tagged , , , , , , , , , . Bookmark the permalink. 4 Comments.

  1. Thanks for the tip, Satheesh!


  2. Awsomeman328

    Does this change the ‘Project Version’ setting in Project Settings or is it it’s own separate thing?


  3. Thanks for the tip! Just a minor tweak I implemented when using this scheme: Directly edit the GameVersion.h from the build.cs file. No need for a Game_build.txt file.


  4. https://polldaddy.com/js/rating/rating.jshttps://polldaddy.com/js/rating/rating.jsHere’s the code to change it directly. Note you should change the path to your version file.
    private void IncrementBuild(TargetInfo Target)
    FileReference EmpiresVersionFile = FileReference.Combine(Target.ProjectFile.Directory, “Source/Empires/Public/EmpiresVersion.h”);
    const string BUILD_NUMBER_TEXT = “#define EMPIRES_BUILD_NUMBER”;
    var FileContents = FileReference.ReadAllText(EmpiresVersionFile, Encoding.UTF8);
    var Split = FileContents.Split(‘\n’);
    var NewContent = string.Empty;
    for (var i = 0; i < Split.Length; i++)
    if (Split[i].Contains(BUILD_NUMBER_TEXT))
    var BuildNumberStr = Split[i].Replace(BUILD_NUMBER_TEXT, "");
    var BuildNumber = Int32.Parse(BuildNumberStr);
    Split[i] = BUILD_NUMBER_TEXT + " " + (BuildNumber.ToString());
    NewContent += Split[i] + "\n";
    FileReference.WriteAllText(EmpiresVersionFile, NewContent, Encoding.UTF8);


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: