Variable of Blueprint Function Library keeps data after stopping game in editor


As written in the title, I have variable TMap in a blueprint function library class which I created to keep data while calling functions of that blueprint function library.

It seems that even after closing the game in editor, map keeps data. After packaging, it does not keep data.

Is there any way to reset map when game is closed in editor? Thanks!

Is it a static variable? If so, that’s completely normal. It would be your responsibility to clean it up after the PIE session ends.

Take a look at this thread where we discussed something similar.

In short: find a suitable point in the game lifecycle and clean up all your statics.

1 Like

Thanks @and-rad
But do you happen to know how to use UGameInstance::OnStart() in a blueprint function library? I am searching ways, have not found yet.

Why would you do that? You override UGameInstance::OnStart and add your own functionality. The engine calls the function when it is time.

Thanks you for your help mate!