Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacob Niedzwiecki
committed
Oct 5, 2019
1 parent
9fc1c41
commit 9f97c7e
Showing
25 changed files
with
1,477 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Cohort Unity Client | ||
|
||
## Getting started | ||
|
||
### Before starting | ||
- make sure your platform is set to iOS (Build Settings > select iOS on left > Switch Platform) | ||
|
||
### Import Cohort Unity client package | ||
- Assets > Import package > Custom package, select 'cohort-unity-client' | ||
|
||
### Import (paid) dependencies from Unity Asset Store | ||
- [BestHTTP](https://assetstore.unity.com/packages/tools/network/best-http-10872) | ||
- [iOS Native Flashlight](https://assetstore.unity.com/packages/tools/integration/ios-native-flashlight-129556) | ||
|
||
### Setting up cues | ||
- look at CohortUnityClient/Scenes/CohortDemoScene for an example | ||
- create a plain GameObject, name it 'CohortManager' | ||
- drag CohortUnityClient/Scripts/CHSession.cs onto the CohortManager GameObject | ||
- for sound cues: | ||
- create an Audio Source GameObject (name it if you want) | ||
- select the CohortManager GameObject | ||
- in the Inspector, under 'CH Session', set the 'Audio Player' field to your Audio Source object | ||
- import your sound files to /Resources (as Audio Clips) | ||
- you can set desired transcode / quality settings under your Audio Clips' Import Settings | ||
- select the CohortManager GameObject | ||
- under CH Session > Sound Cues, set Size to 1 | ||
- under Element 0: | ||
- set the Audio Clip field to one of your Audio Clips | ||
- set Cue Number to 1 (point cue numbers like 10.5 are fine too) | ||
- if the cue has speech: transcribe it in the 'Accessible Alternative' field | ||
- if the cue is music or sound effects: provide a description in the 'Accessible Alternative' field | ||
|
||
### Testing locally | ||
- start an instance of [Cohort Server](https://github.com/jakemoves/cohort-server) running locally | ||
- for this test, make sure you have run the default DB seeds (THIS STEP IS INADEQUATELY DOCUMENTED) | ||
|
||
### Back in Unity... | ||
- under CH Session, enter the following values: | ||
|
||
| | | | ||
|-|-| | ||
| Server URL | localhost | | ||
| Http Port | 3000 | | ||
| Web Socket Path | /sockets | | ||
| Event Id | 4 | | ||
| Client Occasion | 1 | | ||
| Client Tag | any | | ||
|
||
- enter Play mode | ||
- you should see console messages saying "req 1 complete", "req 1.5 complete", and "req 2 complete", as well as "opened websocket connection" | ||
|
||
### Playing sound... | ||
- use a tool like [Postman](https://www.getpostman.com) to send the following JSON as a POST request to 'http://localhost:3000/api/v1/events/4/broadcast' (set the `Content-Type` header to `application/json`): | ||
``` | ||
{ | ||
"mediaDomain": 0, | ||
"cueNumber": 1, | ||
"cueAction": 0, | ||
"targetTags": ["all"] | ||
} | ||
``` | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright Jacob Niedzwiecki, 2019 | ||
// Released under the MIT License (see /LICENSE) | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Cohort { | ||
public class CHMessage { | ||
public List<string> targetTags; | ||
public MediaDomain mediaDomain; | ||
public float cueNumber; | ||
public CueAction cueAction; | ||
public int id; | ||
|
||
public static string FormattedMessage(CHMessage msg) { | ||
string tagsForPrint = ""; | ||
msg.targetTags.ForEach(tag => tagsForPrint = tagsForPrint + tag + ", "); | ||
|
||
return " " + "cohort message: " | ||
+ "\n tags: " + tagsForPrint | ||
+ "\n media domain: " + msg.mediaDomain | ||
+ "\n cue #: " + msg.cueNumber | ||
+ "\n action: " + msg.cueAction; | ||
} | ||
} | ||
|
||
public enum MediaDomain { | ||
sound, | ||
video, | ||
text, | ||
light, | ||
haptic | ||
} | ||
|
||
public enum CueAction { | ||
play, // or "on" | ||
pause, | ||
restart, | ||
stop // or "off" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Assets/Scripts/Test.cs.meta → ...hortUnityClient/Scripts/CHMessage.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.