Process Life Management Gem - Lumberyard User Guide

Process Life Management Gem

Open 3D Engine (O3DE), the successor to Lumberyard, is now available in Developer Preview. Download O3DE or visit the AWS Game Tech blog to learn more.

The Process Life Management gem demonstrates how you can respond to various application lifecycle events dispatched by the Lumberyard engine, in order to pause your game, display a modal splash screen, or anything else you may need to do when your application loses/regains focus.

            Use the Process Life Mangement gem to respond to different application lifecyle

You can access all system-specific events from C++ (even without enabling the Process Life Management gem) by connecting to the appropriate EBus. Lumberyard also generates platform-agnostic events so that you can handle these events for all supported platforms.

Lumberyard Application Lifecycle Events
Lumberyard Application Lifecycle Events iOS Android
OnApplicationConstrained applicationWillResignActive onPause()
OnApplicationUnconstrained applicationDidBecomeActive onResume()
OnApplicationSuspended applicationDidEnterBackground onPause()
OnApplicationResumed applicationWillEnterForeground onResume()
OnMobileApplicationWillTerminate applicationWillTerminate onDestroy()
OnMobileApplicationLowMemoryWarning applicationDidReceiveMemoryWarning onLowMemory()

As demonstrated in ProcessLifeManagementGem.h\ProcessLifeManagementGem.cpp, use the following basic steps to receive process lifecycle events in your game.

To receive process lifecycle events in your game

  1. Derive your class from AzFramework::ApplicationLifecycleEvents::Bus::Handler (or AzFramework::[Ios|Android|Windows]LifecycleEvents::Bus::Handler for platform specific events).

  2. Override the functions corresponding to the events that you want to override:

    void OnApplicationConstrained(Event /lastEvent/) override; void OnApplicationUnconstrained(Event /lastEvent/) override; void OnApplicationSuspended(Event /lastEvent/) override; void OnApplicationResumed(Event /lastEvent/) override
  3. Connect to the event bus when you want to start listening for events. In addition, be sure to disconnect when you no longer want to receive them. Use the following syntax:

    ApplicationLifecycleEvents::Bus::Handler::BusConnect(); … ApplicationLifecycleEvents::Bus::Handler::BusDisconnect();