Having trouble loading data table from config reference (UE4.27)

So my goal was to set up a system where I could quickly change up level sets for my various game modes in project settings during testing.

I made this class to store 3 composite tables in project settings:

UCLASS(Config = Game, defaultconfig, meta = (DisplayName="Level Settings"))
class MARBLE0001_API ULevelSettings : public UDeveloperSettings
{
	GENERATED_BODY()

public:

    UPROPERTY(Config, EditAnywhere, BlueprintReadOnly)
    TSoftObjectPtr<UCompositeDataTable> singlePlayerLevels;

    UPROPERTY(Config, EditAnywhere, BlueprintReadOnly)
    TSoftObjectPtr<UCompositeDataTable> arcadePlaylists;

    UPROPERTY(Config, EditAnywhere, BlueprintReadOnly)
    TSoftObjectPtr<UCompositeDataTable> challengeLevels;
	
};

I then wrote some functions to read these table references:

.h

UCLASS()
class MARBLE0001_API ULevelInfoFunctions : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

    UFUNCTION(BlueprintPure)
    static UCompositeDataTable* getSinglePlayerLevels();

    UFUNCTION(BlueprintPure)
    static UCompositeDataTable* getArcadePlaylists();

    UFUNCTION(BlueprintPure)
    static UCompositeDataTable* getChallengeLevels();

};

.cpp

UCompositeDataTable* ULevelInfoFunctions::getSinglePlayerLevels()
{
    const ULevelSettings* LevelSettings = GetDefault<ULevelSettings>();
    return LevelSettings ? LevelSettings->singlePlayerLevels.Get() : nullptr;
}

UCompositeDataTable* ULevelInfoFunctions::getArcadePlaylists()
{
    const ULevelSettings* LevelSettings = GetDefault<ULevelSettings>();
    return LevelSettings ? LevelSettings->arcadePlaylists.Get() : nullptr;
}

UCompositeDataTable* ULevelInfoFunctions::getChallengeLevels()
{
    const ULevelSettings* LevelSettings = GetDefault<ULevelSettings>();
    return LevelSettings ? LevelSettings->challengeLevels.Get() : nullptr;
}

The issue im having is that when I load the project, only the first (single player levels) data table loads. The others return null UNLESS i re-add the table reference in the project settings, and then they will start working as expected.

Im really confused as to why this is happening, and im hoping it is something that i can fix since its very annoying having to clear and re-set the datatables in the project settings each time I load the project.

Its probably also worth mentioning that I did also try UDataTable also, since the bottom two don’t actually need to be composite, but I thought maybe the issue was that data tables wouldn’t work so I changed them all to comp tables.

The config file looks like this:

[/Script/Marble0001.LevelSettings]
singlePlayerLevels=/Game/Data/Data_LostMarbles/Levels/CData_SinglePlayer.CData_SinglePlayer
arcadePlaylists=/Game/Data/Data_LostMarbles/Levels/CData_ArcadePlaylists.CData_ArcadePlaylists
challengeLevels=/Game/Data/Data_LostMarbles/Levels/CData_Challenges.CData_Challenges

I have tried clearing everything like saved and intermediate folders etc, but none of that seemed to work. I appreciate if anyone has any insight into this issue, thanks!

are you sure they are UCompositeDataTables ?
im using the more generic UDataTable*

probably your problem is that the tsoftobjptr is not loaded.
i do


UDataTable* const Chars = SysSettings->Characters.LoadSynchronous();

but yeah, the regular loading caveats.

I was actually just making an edit to my post when you replied. Originally the arcade and challenge tables were actually just UDataTables, but since the comp table was the only one working, I decided to try changing them all to comps to see if that fixed it, but it didn’t.

Id like to avoid loading synchronously since it would require a lot of reworking, so a blocking load is best for my use in this instance.

everyone does it different, hence my “usual loading caveats”.
but afaik anyway you load it is fine.
also afaik the tsoftobjptr wont keep a ref to it. so it could be unloaded if not used, but i dont know much about that.

good luck i hope that fixes it.

1 Like

So I changed my functions to the following and it seems to have solved the issue:

UCompositeDataTable* ULevelInfoFunctions::getSinglePlayerLevels()
{
    return GetDefault<ULevelSettings>()->singlePlayerLevels.LoadSynchronous();
}

UCompositeDataTable* ULevelInfoFunctions::getArcadePlaylists()
{
    return GetDefault<ULevelSettings>()->arcadePlaylists.LoadSynchronous();
}

UCompositeDataTable* ULevelInfoFunctions::getChallengeLevels()
{
    return GetDefault<ULevelSettings>()->challengeLevels.LoadSynchronous();
}

Thanks nande!

1 Like

im so happy it worked/helped! Well done :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.