Download

Loading BP defaults from a datatable via gameplay tags

In short I’m trying to load defaults for my BP classes from a datatable (which is generated from a CSV file), with the datatable using gameplay tags as the key (well, it uses FName of course, but I pass it a gameplay tag that is converted into an FName to access the table). The problem I’ve found is that the only function that works is PostEditChangeProperty().


void ADefaultsTest::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);

Value = UFunctionDatabase::GetValue(Tag); //converts the tag to FName and searches in the appropriate datatable, returning the float value
}

As you can see I am simply setting a value in this test class. However the issue is this only happens when changing a property in the BP, which is somewhat annoying. I was looking for a way to have this happen without needing to alter something, but I can’t find anything that doesn’t call before gameplay tags or BP values for variables are initialized (Tag is set in BP, so calling it before that is initialized will just send “None”). Is there something that is called:
-after gameplaytag system is initialized
-after BP property values are set
-while in-editor
I’ve tried PostInitProperties() and PostInitializeComponents(), but both seem to give a null Tag value. BeginPlay() and such are obviously too late and will not be called in editor. Again, the main issue is that I wish to pass a gameplay tag from a BP class inheriting from the parent class that has this function override, I could hardcode the tag in C++ and it would work in the constructor, however that would also mean I’d need a C++ for each class, instead of simply having BPs inherit from the parent C++ class.