Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

unity-sdk

:video_game: Unity SDK to use the IBM Watson services.

Subscribe to updates I use unity-sdk


Statistics on unity-sdk

Number of watchers on Github 318
Number of open issues 18
Average time to close an issue 7 days
Main language C#
Average time to merge a PR 2 days
Open pull requests 9+
Closed pull requests 10+
Last commit over 1 year ago
Repo Created over 3 years ago
Repo Last Updated over 1 year ago
Size 312 MB
Organization / Authorwatson-developer-cloud
Latest Release2.0.0
Contributors6
Page Updated
Do you use unity-sdk? Leave a review!
View open issues (18)
View unity-sdk activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating unity-sdk for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Watson APIs Unity SDK

Build Status

Use this SDK to build Watson-powered applications in Unity.

Table of Contents * [Before you begin](#before-you-begin) * [Getting the Watson SDK and adding it to Unity](#getting-the-watson-sdk-and-adding-it-to-unity) * [Installing the SDK source into your Unity project](#installing-the-sdk-source-into-your-unity-project) * [Configuring your service credentials](#configuring-your-service-credentials) * [Authentication](#authentication) * [Watson Services](#watson-services) * [Authentication Tokens](#authentication-tokens) * [Documentation](#documentation) * [Questions](#questions) * [Open Source @ IBM](#open-source--ibm) * [License](#license) * [Contributing](#contributing)

Before you begin

Ensure that you have the following prerequisites:

  • An IBM Cloud account. If you don't have one, sign up.
  • Unity. You can use the free Personal edition.
  • Change the build settings in Unity (File > Build Settings) to any platform except for web player/Web GL. The Watson Developer Cloud Unity SDK does not support Unity Web Player.

Getting the Watson SDK and adding it to Unity

You can get the latest SDK release by clicking here.

Installing the SDK source into your Unity project

Move the unity-sdk directory into the Assets directory of your Unity project. Optional: rename the SDK directory from unity-sdk to Watson.

Configuring your service credentials

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.

  1. Determine which services to configure.
  2. If you have configured the services already, complete the following steps. Otherwise, go to step 3.
    1. Log in to IBM Cloud at https://console.bluemix.net.
    2. Click the service you would like to use.
    3. Click Service credentials.
    4. Click View credentials to access your credentials.
  3. If you need to configure the services that you want to use, complete the following steps.
    1. Log in to IBM Cloud at https://console.bluemix.net.
    2. Click the Create service button.
    3. Under Watson, select which service you would like to create an instance of and click that service.
    4. Give the service and credential a name. Select a plan and click the Create button on the bottom.
    5. Click Service Credentials.
    6. Click View credentials to access your credentials.
  4. Your service credentials can be used to instantiate Watson Services within your application. Most services also support tokens which you can instantiate the service with as well.

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!

Watson Services

To get started with the Watson Services in Unity, click on each service below to read through each of their README.md's and their codes.

Authentication

Before you can use a service, it must be authenticated with the service instance's username, password and url.

using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
using IBM.Watson.DeveloperCloud.Utilities;

void Start()
{
    Credentials credentials = new Credentials(<username>, <password>, <url>);
    Conversation _conversation = new Conversation(credentials);
}

For services that authenticate using an apikey, you can instantiate the service instance using a Credential object with an apikey and url.

using IBM.Watson.DeveloperCloud.Services.VisualRecognition.v3;
using IBM.Watson.DeveloperCloud.Utilities;

void Start()
{
    Credentials credentials = new Credentials(<apikey>, <url>);
    VisualRecognition _visualRecognition = new VisualRecognition(credentials);
}

Callbacks

Success and failure callbacks are required. You can specify the return type in the callback.

private void Example()
{
    //  Call with sepcific callbacks
    conversation.Message(OnMessage, OnGetEnvironmentsFail, _workspaceId, "");
    discovery.GetEnvironments(OnGetEnvironments, OnFail);
}

//  OnMessage callback
private void OnMessage(object resp, Dictionary<string, object> customData)
{
    Log.Debug("ExampleCallback.OnMessage()", "Response received: {0}", customData["json"].ToString());
}

//  OnGetEnvironments callback
private void OnGetEnvironments(GetEnvironmentsResponse resp, Dictionary<string, object> customData)
{
    Log.Debug("ExampleCallback.OnGetEnvironments()", "Response received: {0}", customData["json"].ToString());
}

//  OnMessageFail callback
private void OnMessageFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
    Log.Error("ExampleCallback.OnMessageFail()", "Error received: {0}", error.ToString());
}

//  OnGetEnvironmentsFail callback
private void OnGetEnvironmentsFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
    Log.Error("ExampleCallback.OnGetEnvironmentsFail()", "Error received: {0}", error.ToString());
}

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.

private void Example()
{
    //  Call with generic callbacks
    conversation.Message(OnSuccess, OnMessageFail, "<workspace-id>", "");
    discovery.GetEnvironments(OnSuccess, OnFail);
}

//  Generic success callback
private void OnSuccess<T>(T resp, Dictionary<string, object> customData)
{
    Log.Debug("ExampleCallback.OnSuccess()", "Response received: {0}", customData["json"].ToString());
}

//  Generic fail callback
private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
    Log.Error("ExampleCallback.OnFail()", "Error received: {0}", error.ToString());
}

Custom data

Custom data can be passed through a Dictionary<string, object> customData in each call. In most cases, the raw json response is returned in the customData under "json" entry. In cases where there is no returned json, the entry will contain the success and http response code of the call.

void Example()
{
    Dictionary<string, object> customData = new Dictionary<string, object>();
    customData.Add("foo", "bar");
    conversation.Message(OnSuccess, OnFail, "<workspace-id>", "", customData);
}

//  Generic success callback
private void OnSuccess<T>(T resp, Dictionary<string, object> customData)
{
    Log.Debug("ExampleCustomData.OnSuccess()", "Custom Data: {0}", customData["foo"].ToString());  // returns "bar"
}

//  Generic fail callback
private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
    Log.Error("ExampleCustomData.OnFail()", "Error received: {0}", error.ToString());  // returns error string
    Log.Debug("ExampleCustomData.OnFail()", "Custom Data: {0}", customData["foo"].ToString());  // returns "bar"
}

Authentication Tokens

You use tokens to write applications that make authenticated requests to IBM Watson services without embedding service credentials in every call.

You can write an authentication proxy in IBM Cloud that obtains and returns a token to your client application, which can then use the token to call the service directly. This proxy eliminates the need to channel all service requests through an intermediate server-side application, which is otherwise necessary to avoid exposing your service credentials from your client application.

using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
using IBM.Watson.DeveloperCloud.Utilities;

void Start()
{
    Credentials credentials = new Credentials(<service-url>)
    {
        AuthenticationToken = <authentication-token>
    };
    Conversation _conversation = new Conversation(credentials);
}

There is a helper class included to obtain tokens from within your Unity application.

using IBM.Watson.DeveloperCloud.Utilities;

AuthenticationToken _authenticationToken;

void Start()
{
    if (!Utility.GetToken(OnGetToken, <service-url>, <service-username>, <service-password>))
        Log.Debug("ExampleGetToken.Start()", "Failed to get token.");
}

private void OnGetToken(AuthenticationToken authenticationToken, string customData)
{
    _authenticationToken = authenticationToken;
    Log.Debug("ExampleGetToken.OnGetToken()", "created: {0} | time to expiration: {1} minutes | token: {2}", _authenticationToken.Created, _authenticationToken.TimeUntilExpiration, _authenticationToken.Token);
}

Documentation

Documentation can be found here. You can also access the documentation by selecting API Reference the Watson menu (Watson -> API Reference).

Questions

If you are having difficulties using the APIs or have a question about the IBM Watson Services, please ask a question on dW Answers or Stack Overflow.

Open Source @ IBM

Find more open source projects on the IBM Github Page.

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

Contributing

See CONTRIBUTING.md.

unity-sdk open issues Ask a question     (View All Issues)
  • over 2 years [speech-to-text] keywords: No api to specify keywords or return keyword results
  • over 2 years [microphone-widget] iOS crash for not having microphone usage description in info.plist
  • over 2 years [UnitTestManager] Needs to define project name via inspector
  • almost 3 years [editor][visual-recognition] Visual recognition editor.
  • almost 3 years [TouchEventManager] Dragging locking issue
  • about 3 years Determine code coverage for Unity SDK
  • about 3 years [Widget] Conversation
  • about 3 years [Widget] Tradeoff Analytics
  • about 3 years [Widget] Tone Analyzer
unity-sdk open pull requests (View All Pulls)
  • * Added Project name definition on Unit test
  • * Changed from private to proceed as we are deriving from that camera
  • * Deleted extra callback from touch widget
  • Feature 113 touchmanager
  • Feature 97 integration testing
  • revised version date for conversation to 2016-09-20
  • re: Issue #172
  • added dialogNode data model
  • Add support for Holographic/WSA applications (Hololens)
unity-sdk questions on Stackoverflow (View All Questions)
  • Cardboard unity sdk 0.7 CardboardAudio Renderer effect not found
  • Google Cardboard Unity SDK Tilted not working on a device
  • Facebook Unity SDK for android: Unsupported get request error
  • Facebook for Unity SDK and desktop appplications
  • Can't get Unity SDK to connect to aws hosted parse instance (null ref in GenerateWWWInstance)
  • AdColony unity sdk
  • Tango Unity SDK - TangoPoseSupport and coordinate frames
  • Facebook graph API/FB UNITY SDK handling App Requests (send & receive)
  • Cardboard QR Scanning without Unity SDK
  • Facebook Unity SDK AppRequest not showing notification [Android]
  • Uploading to AWS S3 with PublicRead permission causes error in AWS Unity SDK
  • How to start a tournament in Nextpeer Unity SDK?
  • Facebook-unity-sdk not using iOS native SSO
  • Facebook Unity SDK login via Safari View Controller
  • Facebook Unity SDK how to add like button for (for liking Facebook page)?
  • Unity SDK 7.1.0 + iOS "The redirect_uri URL must be absolute" on login
  • Google Cardboard Unity SDK - detecting back button press
  • How to get user's profile picture with Facebook's Unity SDK?
  • How can I get my profile image with Facebook Unity SDK 7.0.3 Beta?
  • Facebook Unity SDK Login. How to always force in-game WebView login dialog?
  • facebook unity sdk /user/feed embed youtube with link
  • Facebook Unity SDK, how to force login using webview instead of FB App
  • Unity 5.2.2f and Facebook Unity SDK 7.2 AndroidJNI_CUSTOM_NewStringUTF()
  • How to disable Google QR scanner wizard in the unity SDK
  • Getting Texture from IResult (Facebook Unity SDK 7.0.3b)
  • How to set web proxy on facebook-unity-sdk
  • Does facebook unity SDK isLoggedIn persist after app update
  • Which version the Facebook iOS SDK that Facebook Unity SDK v6.2.2 is rely on?
  • Facebook Unity SDK Blank Perm Window
  • Cannot login through facebook unity sdk in android
unity-sdk list of languages used
unity-sdk latest release notes
2.0.0 Watson Developer Cloud Unity SDK v2.0.0

In this major breaking release we implemented both error callbacks and generic success callbacks in the service abstractions. Calls to the service also have an optional Dictionary<string, object> used to hold any data you would like to persist in the callbacks. Speech to text streaming (and examples) are greatly improved. Additionally, The SDK also supports Hololens. See the changelog for details.

1.0.0 Watson Developer Cloud Unity SDK v1.0.0

This is the first major release since the original Watson Developer Cloud Unity SDK. In this release, we remove the higher level Widget architecture to be added later as a separate package. All 3rd party plugins have been updated to their latest versions for compatibility across platforms. Dependency on credentials through a config.json file has been removed in favor of allowing users to choose how they want to consume credentials. Authentication through tokens has also been added. See the changelog for details.

0.13.0 Watson Developer Cloud Unity SDK v0.13.0

The Watson Developer Cloud Unity SDK release v0.13.0 adds Discovery abstraction and other changes including updating build to use Unity 5.5. See changelog for details.

Other projects in C#