What’s the problem? This is really weird. I tried to use both UObject and None Class.
I’ve been dealing with this problem for a week.
class XXX_API UGameManager : public UGameInstance
{
TUniquePtr<LevelManager> level_manager;
...
Init(){
level_manager = TUniquePtr<LevelManager>(new LevelManager());
}
....
}
class LevelManager
{
....
}
//Ticks per second
if (level_manager.Get() == nullptr)
{
UE_LOG(LogTemp, Warning, L"null")
}
else
{
UE_LOG(LogTemp, Warning, L"not null")
}
When I focus on the New Editor Window or move it, this is the result:
Can you profive more info, how do you check whatever level_manager is null or not. And what LeveLManager is? it missing prefix
LevelManager is just a class that has functions and variables. It’s not UObject.
I have a game manager class that inherits UGameInstance and FTickableObject. In Tick function, I check “level_manager” if it is null.
void UGameManager::Tick(float DeltaTime)
{
static float xy = 0;
if (xy >= 1)
{
if (level_manager.Get() == nullptr) // or raw pointer level_manager == nullptr
{
UE_LOG(LogTemp, Warning, L"null")
}
else
{
UE_LOG(LogTemp, Warning, L"not null")
}
xy = 0;
}
xy += DeltaTime;
}
As I said, when I focus on the New Editor Window or move it, when I back to editor and focus on New Editor Window again, it looks “null” or “not null”. It’s always changing.
And This is the level_manager:
enum LEVEL {
NONE = 0,
MAIN = 1,
LOGIN = 2,
CREATE_CHARACTER = 3,
};
class UGameManager;
class ULoginWidget;
class XXX_API LevelManager
{
private:
uint16 m_current_level = 0;
TMap<uint16, FName> m_levels;
public:
LevelManager();
~LevelManager();
FORCEINLINE uint16 GetCurrentLevel() const { return m_current_level; }
void OpenLevel(uint16 level_code);
void LoadLogin();
};