:video_game: 使用 IBM Watson 服务的 Unity SDK。
This repo and its associated release binaries are being deprecated. While this repo will no longer see active support from the IBM team, contributions by the community via PRs are still welcomed and will be reviewed. Keep in mind, updates will no longer be published into release binaries and changes made after this update will need to be compiled independently.
Use this SDK to build Watson-powered applications in Unity.
As of this major release, 6.0.0, the Tone Analyzer API has been removed in preparation for deprecation. If you wish to continue using this sdk to make calls to Tone Analyzer until its final deprecation, you will have to use a previous version. On 24 February 2022, IBM announced the deprecation of the Tone Analyzer service. The service will no longer be available as of 24 February 2023. As of 24 February 2022, you will not be able to create new instances. Existing instances will be supported until 24 February 2023.
As an alternative, we encourage you to consider migrating to the Natural Language Understanding service on IBM Cloud. With Natural Language Understanding, tone analysis is done by using a pre-built classifications model, which provides an easy way to detect language tones in written text. For more information, see Migrating from Watson Tone Analyzer Customer Engagement endpoint to Natural Language Understanding.
As of this major release, 6.0.0, the NLC API has been removed in preparation for deprecation. If you wish to continue using this sdk to make calls to NLC until its final deprecation, you will have to use a previous version. On 9 August 2021, IBM announced the deprecation of the Natural Language Classifier service. The service will no longer be available from 8 August 2022. As of 9 September 2021, you will not be able to create new instances. Existing instances will be supported until 8 August 2022. Any instance that still exists on that date will be deleted.
As an alternative, we encourage you to consider migrating to the Natural Language Understanding service on IBM Cloud that uses deep learning to extract data and insights from text such as keywords, categories, sentiment, emotion, and syntax, along with advanced multi-label text classification capabilities, to provide even richer insights for your business or industry. For more information, see Migrating to Natural Language Understanding.
Watson API endpoint URLs at watsonplatform.net are changing and will not work after 26 May 2021. Update your calls to use the newer endpoint URLs. For more information, see https://cloud.ibm.com/docs/watson?topic=watson-endpoint-change.
Ensure that you have the following prerequisites:
Updating MacOS to Mojave may disable microphone for Unity. If you are running into this issue please see these guidelines to configure microphone for Mojave.
You can get the latest SDK release by clicking [here][latest_release_sdk]. You will also need to download the latest release of the IBM Unity SDK Core by clicking [here][latest_release_core].
Move the unity-sdk and unity-sdk-core directories into the Assets directory of your Unity project. Optional: rename the SDK directory from unity-sdk to Watson and the Core directory from unity-sdk-core to IBMSdkCore.
To create instances of Watson services and their credentials, follow the steps below.
Note: Service credentials are different from your IBM Cloud account username and password.
The credentials for each service contain either a username, password and endpoint url or an apikey and endpoint url.
WARNING: You are responsible for securing your own credentials. Any user with your service credentials can access your service instances!
To get started with a Watson Service in Unity, follow the link to see the code.
Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services:
url and either apikey or username and password.In your code, you can use these values in the service constructor or with a method call after instantiating your service.
Some services use token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
You supply either an IAM service API key or an access token:
HasIamTokenData() returns true.…
Authenticator authenticator;
AssistantService assistant;
string versionDate = "";
void TokenExample()
{
// Create authenticator using the Bearer Token
authenticator = new BearerTokenAuthenticator("");
assistant = new AssistantService(versionDate, authenticator);
assistant.SetServiceUrl("");
assistant.ListWorkspaces(callback: OnListWorkspaces);
}
private void OnListWorkspaces(DetailedResponse response, IBMError error)
{
Log.Debug("OnListWorkspaces()", "Response: {0}", response.Response);
}
Authenticator authenticator;
AssistantService assistant;
string versionDate = "";
void UsernamePasswordExample()
{
Authenticator authenticator = new BasicAuthenticator("", "", "");
assistant = new AssistantService(versionDate, authenticator);
assistant.SetServiceUrl("");
}
There are two ways to supply the authenticator you found above to the SDK for authentication.
With a credential file, you just need to put the file in the right place and the SDK will do the work of parsing it and authenticating. You can get this file by clicking the Download button for the credentials in the Manage tab of your service instance.
The file downloaded will be called ibm-credentials.env. This is the name the SDK will search for and must be preserved unless you want to configure the file path (more on that later). The SDK will look for your ibm-credentials.env file in the following places (in order):
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following:
public IEnumerator ExampleAutoService()
{
Assistant assistantService = new Assistant("2019-04-03");
// Wait for authorization token
while (!assistantService.Authenticator.CanAuthenticate())
yield return null;
var listWorkspacesResult = assistantService.ListWorkspaces();
}
And that's it!
If you're using more than one service at a time in your code and get two different ibm-credentials.env files, just put the contents together in one ibm-credentials.env file and the SDK will handle assigning authenticator to their appropriate services.
If you would like to configure the location/name of your credential file, you can set an environment variable called IBM_CREDENTIALS_FILE. This will take precedence over the locations specified above. Here's how you can do that:
export IBM_CREDENTIALS_FILE=""
where `` is something like /home/user/Downloads/.env.
If you'd prefer to set authentication values manually in your code, the SDK supports that as well. The way you'll do this depends on what type of authenticator your service instance gives you.
A success callback is required. You can specify the return type in the callback.
…
Since the success callback signature is generic and the failure callback always has the same signature, you can use a single set of callbacks to handle multiple calls.
暂无开放 Issues,或尚未同步最近议题。