In this post we’re going to see how to create a basic File Picker inside Unreal Engine. We’re going to use the built-in tools that the engine provides and read a text file.

Download the entire source code from my GitHub repo

Adding the required Dependencies

For this post I have created a C++ project using the 4.20 version of the engine. Then, I added the SlateCore dependency in the public module names in the <MyProject>.Build.cs file:

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

Creating the file picker

Ideally, you will place the functionality of the file picker in a utility library so you can use it throughout your project. However I’ve added the code inside the character code just for demonstration purposes.

I have created two functions, one that is responsible for opening and displaying the file picker and one which is responsible for getting the contents of the selected file:

Before implementing the logic for each function, make sure to include the following header files in your class:

The reason we need to include them is so we can have access to the deskplatform code where the built-in file picker exists.

Here’s the implementation of each function:

After compiling my code, I created the following BP code to read the contents of the single file I selected:

(Click on image to enlarge in a new tab)

Here is how the file dialog looks from within the engine:

(Click on image to enlarge in a new tab)

It’s worth noting that depending on the files that you want to read your print/parse data function may differ from this post. If you want to be able to select any data type you can leave the file types string empty.