Hi everyone. I’ve singleton c++ UObject class wich i call in blueprint widget.
.H
private:
/* Constructor */
UNetworkManager();
/* Singleton */
static UNetworkManager *instance;
public:
UFUNCTION(BlueprintCallable, Category = "NetworkManager")
static UNetworkManager *Instance();
.CPP
/* Singleton */
UNetworkManager *UNetworkManager::instance = NULL;
/* Singleton */
UNetworkManager *UNetworkManager::Instance()
{
if(!instance)
instance = NewObject<UNetworkManager>();
return instance;
}
Widget
At first all work fine, but some time after i get an error:
LogScript:Warning: Attempted to access NetworkManager_0 via property CallFunc_Instance_ReturnValue, but NetworkManager_0 is pending kill
AuthLevelWidget_C /Engine/Transient.UnrealEdEngine_0:GameInstance_0.AuthLevelWidget_C_0
Function /Game/AuthLevel/AuthLevelWidget.AuthLevelWidget_C:ExecuteUbergraph_AuthLevelWidget:00A6
I think it happens because the Garbage Collector remove the class, but i’m not sure.
How to fix it ?
Hope somebody help me.
Thanks.