I’ve got a GameInstance C++ class. Defined UPROPERTY(EditAnywhere) FString Test; in the header. Created a BP derived from the C++ class, set the Test string content there.
But, when I run the code, which uses only the C++ class (I don’t have any idea if i should somehow force the execution to use the BP instead), the FString Test, when printed out is empty.
How do I add blueprintable properties that will actually provide the data to the C++ class?
1 Like
That’s how it should work. With EditAnywhere, you change it in the blueprint and it’s changed for the class instance, regardless of where you’re using it. There must be something else that affects your string.
3 Likes
UCLASS()
class PUZZLEPLATFORMS_API UPuzzlePlatformsGameInstance : public UGameInstance, public IMenuInterface
{
GENERATED_BODY()
public:
//public members
private:
UPROPERTY(EditAnywhere)
FString Test;
//the rest of the h file
and in the cpp file
void UPuzzlePlatformsGameInstance::OnCreateSessionComplete(FName CurrentSessionName, bool SessionCreated)
{
UE_LOG(LogTemp, Warning, TEXT("bruh: %s"), *Test);
}
Those are the only places Test variable is touched in any way. I honestly have no idea why it’s not working or what can I be doing wrong
1 Like
Make sure you assign the BP you changed the variable in as the game instance class used by the game in the project settings.
3 Likes
Yup, i thought I had to go through the BP somehow, but didn’t think to do it that way. I wasted soo much time on this, thank you so much! <3
1 Like