GUADeviceLevelResultObserver
[MSDK & Player Network SDK] Registers the callback of the device level module, the game needs to process the callback function. For more information on the callback data structure, see GUADeviceLevelResult.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function Definition
- Unity
- Unreal Engine
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
DeviceLevelResultEvents | - | QueryDeviceLevel | - |
event OnResultHandler<GUADeviceLevelResult> DeviceLevelResultEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnDeviceLevelNotify | - | QueryDeviceLevel | - |
class GUA_EXTERN GUADeviceLevelObserver
{
public:
virtual ~GUADeviceLevelObserver() {};
virtual void OnDeviceLevelNotify(const GUADeviceLevelResult &device_level_result) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetReportService().DeviceLevelResultEvents += OnDeviceLevelResult;
// Remove callbacks
UnionAdapterAPI.GetReportService().DeviceLevelResultEvents -= OnDeviceLevelResult;
// DeviceLevelResultEvents callback
private void OnDeviceLevelResult(GUADeviceLevelResult ret)
{
Debug.Log("Query Device Level " + ret.DeviceLevel);
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUADeviceLevelObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnDeviceLevelNotify
class FGUADeviceLevelObserver : public GUA_NAMESPACE::GUADeviceLevelObserver
{
public:
static FGUADeviceLevelObserver Instance;
void OnDeviceLevelNotify(const GUA_NAMESPACE::GUADeviceLevelResult &device_level_result)
{
}
};
FGUADeviceLevelObserver FGUADeviceLevelObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAReportService::SetDeviceLevelObserver(&FGUADeviceLevelObserver::Instance);