Download

UObject percists even after code is changed

I have a class derived from UObject having a FTickableGameObject for custom ticks. And print out a a string debug message.

I am only spawning 1 instance of the class in my game. But some times more than 1 instance of the object is present in the game. And when I change my debug printout message and hot reload, the old debug messages still persist.

This gets solved when I restart the editor and I cannot intentionally recreate it.

How do you change the message, in code? I can’t say much without seeing the code, but it sounds like it could be related to the class default object.

If you only ever want one instance of that object in the game, my advice would be to make it a static, and make sure that the code fires an assert if you start spawning a second one. That way you’ll also get a callstack and should be able to find out why it’s happening. Something like:



UMyObject::SpawnStaticObject
{
    if (MyStaticObject != nullptr)
    {
         ASSERT(TEXT("Trying to spawn new '' when one already exists!")
    }
}