ToolsResultObserver
Register the callback of the Player Network SDK Tools module, the game needs to process the callback function. For more information on the callback data structure, see GUAToolsResult.
note
[Player Network SDK & MSDK] 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] |
---|---|---|---|
ToolsResultEvents | ConvertShortUrl | - | - |
event OnResultHandler<GUAToolsResult> ToolsResultEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnToolsResultNotify | ConvertShortUrl | - | - |
class GUA_EXTERN GUAToolsObserver
{
public:
virtual ~GUAToolsObserver(){};
virtual void OnToolsResultNotify(const GUAToolsResult &tools_ret) {};
};
Code Sample
- Unity
- Unreal Engine
UnionAdapterAPI.GetToolsService().ToolsResultEvents += OnToolsResult;
UnionAdapterAPI.GetToolsService().ToolsResultEvents -= OnToolsResult;
private void OnToolsResult(GUAToolsResult result)
{
string methodTag = "";
if (result.MethodId == (int)GUAMethodID.GUA_TOOLS_CONVERT_SHORT_URL)
{
methodTag = "CoverShortUrl";
}
Debug.Log(methodTag + result.ToString());
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUAToolsObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnToolsResultNotify
class FGUAToolsObserver : public GUA_NAMESPACE::GUAToolsObserver{
public:
static FGUAToolsObserver Instance;
void OnToolsResultNotify(const GUA_NAMESPACE::GUAToolsResult &ret)
{
}
};
FGUAToolsObserver FGUAToolsObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAToolsService::SetToolsObserver(&FGUAToolsObserver::Instance);