I have a component that needs to run some code in the event of game/editor/program shutdown.
I have set up the component to get callbacks from ISystemEventListener and CrySystemEventBus.
I am receiving some events to my component, so I am pretty sure it is setup correctly, but I am not receiving the shutdown related events.
Headers are included:
#include <ISystem.h> // for ISystemEventListener #include <CrySystemBus.h> // for CrySystemEventBus
Classes are inherited
class myComponent
: public AZ::Component
, public CrySystemEventBus::Handler
, public ISystemEventListener
Functions are overridden:
void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
void OnCrySystemPreInitialize(ISystem& system, const SSystemInitParams& systemInitParams) override;
void OnCrySystemShutdown(ISystem& system) override;
For example, this is working:
void myComponent::OnCrySystemCVarRegistry()
{
AZ_TracePrintf("myComponent", "OnCrySystemCVarRegistry");
}
This is not working:
void myComponent::OnCrySystemShutdown(ISystem& system)
{
AZ_TracePrintf("myComponent", "OnCrySystemShutdown");
}
In the below, ESYSTEM_EVENT_GAME_POST_INIT, SYSTEM_EVENT_GAME_POST_INIT_DONE, and ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED are working, but ESYSTEM_EVENT_LEVEL_UNLOAD, ESYSTEM_EVENT_FULL_SHUTDOWN, ESYSTEM_EVENT_FAST_SHUTDOWN are not working.
void myComponent::OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam)
{
switch (event)
{
case ESYSTEM_EVENT_GAME_POST_INIT:
AZ_TracePrintf("myComponent", "ESYSTEM_EVENT_GAME_POST_INIT");
break;
case ESYSTEM_EVENT_GAME_POST_INIT_DONE:
AZ_TracePrintf("myComponent", "ESYSTEM_EVENT_GAME_POST_INIT_DONE");
break;
case ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED:
AZ_TracePrintf("myComponent", "ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED");
break;
case ESYSTEM_EVENT_LEVEL_UNLOAD:
AZ_TracePrintf("myComponent", "ESYSTEM_EVENT_LEVEL_UNLOAD");
break;
case ESYSTEM_EVENT_FULL_SHUTDOWN:
AZ_TracePrintf("myComponent", "ESYSTEM_EVENT_FULL_SHUTDOWN");
break;
case ESYSTEM_EVENT_FAST_SHUTDOWN:
AZ_TracePrintf("myComponent", "ESYSTEM_EVENT_FAST_SHUTDOWN");
break;
}
}
To see if it might be something with my component, I went and added AZ_TracePrintf to Starter Game in StarterGameGemModule.cpp in the OnSystemEvent function, and I also didn't see any log output. I've also tried adding breakpoints and none of those were triggered.
Is there something I am missing here? Thanks for the help!
@REDACTEDUSER
@REDACTEDUSER
@REDACTEDUSER