AIPlayer Set up
- Step 1: Configure Unity Scene (AIHumanSDK, AIPlayer, AIPlayerUI prefab placement)
- Step 2: Prepare AppID, authentication key, and platform that will be used in the Authenticate function
- Step 3: Get the AI to use by implementing the Authenticate response
- Step 4: Initialize AIPlayer to the desired AI
Step 1. Configure Unity Scene
- Configure the scene by referring to AI Human QuickStart.
- It is not necessary to use the AIHumanSDK prefab. Since AIHumanSDK Prefab and AIHumanSDKManager scripts are provided for SDK user convenience, you can call the AIHumanSDKManager.Authenticate(appId, userKey, platform) function.
- The AIPlayerUI prefab is also provided for SDK user convenience, so it is not necessary to use it, and you can create a custom UI or material to apply the textures provided by AIPlayer.
Step 2. Prepare authentication-related information
The Authenticate function requires 3 parameters. These four are AppID, UserKey, and Platform information.
UserKey is a unique string generated by DeepBrain AI and should never be disclosed. If you call the API using this authentication key, you will receive available Default AI data and a token to be used in the future. Platform selects one of Android, iOS, and Windows in consideration of the user's App Platform.
If token refresh is required because the token expired, it can be refreshed by calling Authenticate() again.
Step 3. Implement Authenticate and Get the AI list
If you have prepared all the necessary information in the second step process, preparations for authentication are completed. We deliver authentication information as a parameter of the AIHumanSDKManager.Authenticate function and implement the callback function. Request a list of available AIs if authentication is successful.
string message = string.Empty;
AIError authError = AIHuman.SDK.AIHumanSDKManager.Instance.Authenticate("appId", "userKey", "platform")
if (authError == null) // success authenticate
{
AIAPI.Instance.GetAIList(AIListType.All, (aiList, aiError) =>
{
if (aiError == null)
{
if (aiList != null)
{
message = string.Format("Auth Complete, Avaliable Count : {0}", aiList.ai.Length);
/* e.g.)
"ai":[{"aiName":"vida","aiDisplayName":"Vida","language":"en"},
{"aiName":"bret","aiDisplayName":"Bret","language":"en"},
{"aiName":"danny","aiDisplayName":"Danny","language":"en"},
{"aiName":"kang","aiDisplayName":"Kang","language":"ko"}]
*/
}
}
else
{
message = string.Format("API Error : {0}", aiError.Description);
}
});
}
else
{
message = string.Format("Auth Error : {0}", authError.Description);
}
Debug.Log(message);
Step 4. Initialize AIPlayer to the desired AI
After checking the list of AIs that can be authenticated and used, the initialization process of AIPlayer is required to apply the desired AI. You can call the AIPlayer.Init(string aiName, IAIPlayer Callback callback, IFrameImageProvider imageProvider) function, and you can also call the Init() function when you need to replace it with another AI.
If the AIPlayer is successfully initialized, the AIPlayer downloads the resource according to the set value and changes to an operational state. In addition, when calling the AIPlayer.Init() function, the AI operational status can be reported in the AIPlayerCallback passed as a parameter.