Skip to content

Commit d194dbd

Browse files
authored
Merge pull request #547 from watson-developer-cloud/feature-v3-update-readme
docs: Updated README.md
2 parents 8d50ccd + c9ade93 commit d194dbd

File tree

2 files changed

+75
-29
lines changed

2 files changed

+75
-29
lines changed

README.md

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,21 @@ Ensure that you have the following prerequisites:
3232

3333
## Configuring Unity
3434
* Change the build settings in Unity (**File > Build Settings**) to any platform except for web player/Web GL. The IBM Watson SDK for Unity does not support Unity Web Player.
35-
* If using Unity 2018.2 or later you'll need to set Scripting Runtime Version and Api Compatibility Level in Build Settings to .NET 4.x equivalent. We need to access security options to enable TLS 1.2.
35+
* If using Unity 2018.2 or later you'll need to set **Scripting Runtime Version** and **Api Compatibility Level** in Build Settings to **.NET 4.x equivalent**. We need to access security options to enable TLS 1.2.
3636

3737
## Getting the Watson SDK and adding it to Unity
3838
You can get the latest SDK release by clicking [here][latest_release].
3939

4040
### Installing the SDK source into your Unity project
41-
1. Move the **`unity-sdk`** directory into the **`Assets`** directory of your Unity project. _Optional: rename the SDK directory from `unity-sdk` to `Watson`_.
42-
2. Using the command line, from the sdk directory run `git submodule init` and `git submodule update` to get the correct commit of the SDK core.
41+
Move the **`unity-sdk`** directory into the **`Assets`** directory of your Unity project. _Optional: rename the SDK directory from `unity-sdk` to `Watson`_.
42+
43+
The SDK depends on the [IBM Unity SDK Core](https://github.com/IBM/unity-sdk-core/) which is added to the SDK as a submodule. Use git to initalize and update the submodule.
44+
45+
```bash
46+
$ cd [watson-unity-sdk-directory]
47+
$ git submodule init
48+
$ git submodule update
49+
```
4350

4451
## Configuring your service credentials
4552
To create instances of Watson services and their credentials, follow the steps below.
@@ -67,19 +74,19 @@ The credentials for each service contain either a `username`, `password` and end
6774

6875
## Watson Services
6976
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.
70-
* [Assistant V1](/Scripts/Services/Assistant/v1)
71-
* [Assistant V2](/Scripts/Services/Assistant/v2)
72-
* [Compare Comply V1](/Scripts/Services/CompareComply/v1)
73-
* [Conversation](/Scripts/Services/Conversation/v1) (deprecated - Use Assistant V1 or Assistant V2)
74-
* [Discovery](/Scripts/Services/Discovery/v1)
75-
* [Language Translator V3](/Scripts/Services/LanguageTranslator/v3)
76-
* [Natural Language Classifier](/Scripts/Services/NaturalLanguageClassifier/v2)
77-
* [Natural Language Understanding](/Scripts/Services/NaturalLanguageUnderstanding/v1)
78-
* [Personality Insights](/Scripts/Services/PersonalityInsights/v3)
79-
* [Speech to Text](/Scripts/Services/SpeechToText/v1)
80-
* [Text to Speech](/Scripts/Services/TextToSpeech/v1)
81-
* [Tone Analyzer](/Scripts/Services/ToneAnalyzer/v3)
82-
* [Visual Recognition](/Scripts/Services/VisualRecognition/v3)
77+
* [Assistant V1](/Scripts/Services/Assistant/V1)
78+
* [Assistant V2](/Scripts/Services/Assistant/V2)
79+
* [Compare Comply V1](/Scripts/Services/CompareComply/V1)
80+
* [Conversation](/Scripts/Services/Conversation/V1) (deprecated - Use Assistant V1 or Assistant V2)
81+
* [Discovery](/Scripts/Services/Discovery/V1)
82+
* [Language Translator V3](/Scripts/Services/LanguageTranslator/V3)
83+
* [Natural Language Classifier](/Scripts/Services/NaturalLanguageClassifier/V2)
84+
* [Natural Language Understanding](/Scripts/Services/NaturalLanguageUnderstanding/V1)
85+
* [Personality Insights](/Scripts/Services/PersonalityInsights/V3)
86+
* [Speech to Text](/Scripts/Services/SpeechToText/V1)
87+
* [Text to Speech](/Scripts/Services/TextToSpeech/V1)
88+
* [Tone Analyzer](/Scripts/Services/ToneAnalyzer/V3)
89+
* [Visual Recognition](/Scripts/Services/VisualRecognition/V3)
8390

8491
## Authentication
8592
Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
@@ -119,13 +126,13 @@ IEnumerator TokenExample()
119126
};
120127

121128
// Create credentials using the IAM token options
122-
_credentials = new Credentials(iamTokenOptions, "<service-url>");
123-
while (!_credentials.HasIamTokenData())
129+
credentials = new Credentials(iamTokenOptions, "<service-url>");
130+
while (!credentials.HasIamTokenData())
124131
yield return null;
125132

126-
_assistant = new Assistant(_credentials);
127-
_assistant.VersionDate = "2018-02-16";
128-
_assistant.ListWorkspaces(OnListWorkspaces);
133+
assistant = new Assistant(credentials);
134+
assistant.VersionDate = "2019-03-28";
135+
assistant.ListWorkspaces(OnListWorkspaces);
129136
}
130137

131138
private void OnListWorkspaces(DetailedResponse<WorkspaceCollection> response, IBMError error)
@@ -145,11 +152,11 @@ void TokenExample()
145152
};
146153

147154
// Create credentials using the IAM token options
148-
_credentials = new Credentials(iamTokenOptions, "<service-url");
155+
credentials = new Credentials(iamTokenOptions, "<service-url");
149156

150-
_assistant = new Assistant(_credentials);
151-
_assistant.VersionDate = "2018-02-16";
152-
_assistant.ListWorkspaces(OnListWorkspaces);
157+
assistant = new Assistant(credentials);
158+
assistant.VersionDate = "2018-02-16";
159+
assistant.ListWorkspaces(OnListWorkspaces);
153160
}
154161

155162
private void OnListWorkspaces(DetailedResponse<WorkspaceCollection> response, IBMError error)
@@ -166,17 +173,17 @@ using IBM.Cloud.SDK.Utilities;
166173
void Start()
167174
{
168175
Credentials credentials = new Credentials(<username>, <password>, <url>);
169-
Assistant _assistant = new Assistant(credentials);
176+
Assistant assistant = new Assistant(credentials);
170177
}
171178
```
172179

173180
## Callbacks
174-
Success callbacks are required. You can specify the return type in the callback.
181+
A success callback is required. You can specify the return type in the callback.
175182
```cs
176183
private void Example()
177184
{
178185
// Call with sepcific callbacks
179-
assistant.Message(OnMessage, _workspaceId);
186+
assistant.Message(OnMessage, workspaceId);
180187
discovery.GetEnvironments(OnGetEnvironments);
181188
}
182189

@@ -209,6 +216,45 @@ private void OnSuccess<T>(DetailedResponse<T> resp, IBMError error)
209216
}
210217
```
211218

219+
You can also use an anonymous callback
220+
```cs
221+
private void Example()
222+
{
223+
assistant.ListWorkspaces(
224+
callback: (DetailedResponse<WorkspaceCollection> response, IBMError error) =>
225+
{
226+
Log.Debug("xampleCallback.OnSuccess()", "ListWorkspaces result: {0}", response.Response);
227+
},
228+
pageLimit: 1,
229+
includeCount: true,
230+
sort: "-name",
231+
includeAudit: true
232+
);
233+
}
234+
```
235+
236+
You can check the `error` response to see if there was an error in the call.
237+
```cs
238+
private void Example()
239+
{
240+
// Call with sepcific callbacks
241+
assistant.Message(OnMessage, workspaceId);
242+
}
243+
244+
// OnMessage callback
245+
private void OnMessage(DetailedResponse<JObject> resp, IBMError error)
246+
{
247+
if(error == null)
248+
{
249+
Log.Debug("ExampleCallback.OnMessage()", "Response received: {0}", resp.Response);
250+
}
251+
else
252+
{
253+
Log.Debug("ExampleCallback.OnMessage()", "Error received: {0}, {1}, {3}", error.StatusCode, error.ErrorMessage, error.Response);
254+
}
255+
}
256+
```
257+
212258
## Custom Request Headers
213259
You can send custom request headers by adding them to the service.
214260

0 commit comments

Comments
 (0)