Woke up this morning determined to establish a data pipeline from Excel to Unreal Engine. The process I wanted was scattered across multiple forum answers and official documents, so I’ve compiled them here for easy access.
Caveat: I make no claims to the robustness of this process, and it is subject to change with further experimentation and development.
Use data created in Excel spreadsheets as variables in Unreal Engine Blueprints.
Create Data and Import
- Decide on data types and organization. To help with this, create a Blueprint Structure in Unreal and review the available types:
- Right-Click (RC) in Content Browser > Create Advanced Asset > Blueprints > Structure.
- Name the Structure.
- Double-Left-Click (DC) the new Structure. You’ll end up replacing MemberVar_x with your column names from the Excel spreadsheet. Consider the data types from the drop-down list.
- Create the spreadsheet in Excel, assigning column names as above. Important: in order for the import/export step to work, a blank-named column of row names must precede your data.
- Here’s where things get a little messy, and this is due to Excel’s default .CSV save function: it does not add quotation marks around the data values, which are required by Unreal. To remedy this, follow these steps to install an appropriate macro. Yes, it’s a bit of a pain, but it’s necessary to make this process work.
- Select the data to export, including the first blank-named column, and run the macro. Save the file with the .CSV extension somewhere you can find it from the Content Browser.
- Edit the Structure you created in step 1, or create a new one, assigning the names with exact matches to your column names in the Excel spreadsheet, and matching the data types to the column data types.
- Save the Structure.
- RC in Content Browser > Import Asset > Import to… > Navigate and Open your exported .CSV file.
- Import As: DataTable > Choose DataTableRow Type: Your Structure > OK. If there are no errors this will create a Data Table asset in the Content Browser with the name of your .CSV file. Note that there’s no hotlinking happening here, and you must repeat the save/import process to update the values.
- Double-check the imported data by DC the Data Table asset. Here you can also make manual edits if you decide to abandon the original spreadsheet, just note that re-importing will overwrite any changes made.
Using the Data
- Create a new Blueprint or navigate to one you want to access the data from.
- In the Blueprint’s Construction Script or Event Graph, RC > Search > Utilities: Get Data Table Row.
- Select the source Data Table from the drop-down menu on the Node, or select it from the Content Browser and use the arrow-insert.
- Pull a wire from the Out Row pin > Utilities > Break
- You now have access to the data.
As you can see, the Row Name is using the names assigned to the first blank column from the Excel spreadsheet. You can use something more descriptive, and it’s a good idea to establish a clear data management naming convention here, such as “Weapon – Handguns – Glock 19″ or “Damage – Fire Skills – Fireball”, or whatever makes the most sense to you. It might also be advisable to use many different data tables rather than one gigantic one, but again that comes down to personal preference.
I hope this helps out, and happy Blueprinting!
- Unreal Engine Documentation – Data Driven Gameplay Elements
- Tulrath – Import Actor Reference from CSV to Data Table?
- DerCrow – …access variables in a Data Table from Blueprint?
- Michael Shnitzer – …force excel to quote all columns of a CSV file?
Working in a vacuum sucks.