Language:
Page Info
Engine Version:

1. Set Up Module Dependencies for UMG

Choose your OS:

If you are new to Unreal Engine 4, you might want to read our Programming Quick Start tutorial first. For this tutorial, we will assume you are familiar with creating a project, adding C++ code to it, and compiling your code. We will also expose functions and properties to Blueprint. If you would like to learn more about that, the Variables, Timers, and Events tutorial is a good place to start.

  1. We will begin by creating a new project:

    • Select the C++ tab.

    • Select Basic Code.

    • Leave the default values of Desktop/Console and With Starter Content.

    • We will use the name HowTo_UMG.

    UMG_ProjectSetup.png

    Since we're going to write code that uses Unreal Motion Graphics (UMG), we'll need to go into Visual Studio include a few modules that aren't available by default.

  2. We can get to our project's code by using the Open Visual Studio command from the File dropdown menu on the main editor screen.

    OpenVisualStudio.png

  3. UMG is dependent on a few modules, so we'll need to add those modules to HowTo_UMG.Build.cs.

    BuildCS.png

    In HowTo_UMG.Build.CS, we need to add UMG to the list of included public modules, and Slate and SlateCore to the list of included private modules. We'll need to modify the first line in HowTo_UMG's constructor to read as follows:

    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG" });

    And then we can uncomment the following line:

    PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

    As usual, full source code is provided below so you can double-check your code.


With UMG set up, we can add code to our project's custom Game Mode to create and display our game's menus.

Work-In-Progress Code

HowTo_UMG.Build.cs

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class HowTo_UMG : ModuleRules
{
    public HowTo_UMG(TargetInfo Target)
    {
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG" });

        //PrivateDependencyModuleNames.AddRange(new string[] {  });

        // Uncomment if you are using Slate UI
        PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");
        // if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
        // {
        //      if (UEBuildConfiguration.bCompileSteamOSS == true)
        //      {
        //          DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
        //      }
        // }
    }
}