Description

DataTables exported to JSON in editor (UDataTable::WriteTableAsJSON, accessible by right clicking a data table and picking export to json) that contain variables with spaces or other outlawed characters cannot be reloaded in engine(UDataTable::CreateTableFromJSONString) in a cooked game because the name information is missing in cooked builds . The attached image shows an example, "Type With Spaces" will not properly export and import, while TypeWithNoSpaces is fine.

The reporter identified a discrepancy (Editor vs Engine) when calling UUserDefinedStruct::GetAuthoredNameForField. The editor will return a friendly name (ie with spaces) while the a cooked build will return the actual FName. For most variable names this will be the same.

The core of this problem is that FMemberVariableNameHelper::Generate is using a very restrictive list of invalid characters via INVALID_OBJECTNAME_CHARACTERS, and will mangle any name that uses them in a way that can't easily be recovered from. This is more restrictive than blueprint variables which use UE_BLUEPRINT_INVALID_NAME_CHARACTERS that only outlaws "."

Steps to Reproduce

There's no easy repro right now for this because none of our games allow importing data in a cooked build. Here is a programmer repro:

  1. Create a user defined struct like the one in the screenshot that has a variable with a space in it
  2. Make a data table using that struct, and then set data in it
  3. Right click data table in editor, pick export to json, save json somewhere. Note that the exported json data will a property with spaces in it
  4. Comment out the "#if WITH_EDITOR" block in UUserDefinedStruct::GetAuthoredNameForField, rebuild and open editor again
  5. Export data table again, note that the exported json will not have spaces

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-96724 in the post.

3
Login to Vote

Backlogged
ComponentUE - Gameplay - Blueprint
Affects Versions4.25
CreatedAug 11, 2020
UpdatedNov 27, 2023