Skip to content

Commit

Permalink
Added README, tested it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Niedzwiecki committed Oct 5, 2019
1 parent 9fc1c41 commit 9f97c7e
Show file tree
Hide file tree
Showing 25 changed files with 1,477 additions and 25 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Expand Up @@ -10,15 +10,23 @@
/[Ll]ogs/
/[Mm]emoryCaptures/

# For macOS
.DS_Store

# meta files
*.meta
/**/*.meta

# For Cohort
/**/Best HTTP (Pro)
/**/FlashLight

# Never ignore Asset meta data
!/[Aa]ssets/**/*.meta


#... unless it's an external lib
Assets/Best HTTP (Pro).meta
Assets/FlashLight.meta

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
Expand Down
File renamed without changes.
62 changes: 62 additions & 0 deletions Assets/CohortUnityClient/README.md
@@ -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"]
}
```

7 changes: 7 additions & 0 deletions Assets/CohortUnityClient/README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/CohortUnityClient/Resources.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/CohortUnityClient/Resources/meow.aiff
Binary file not shown.
22 changes: 22 additions & 0 deletions Assets/CohortUnityClient/Resources/meow.aiff.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Expand Up @@ -294,6 +294,133 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1392766430
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1392766432}
- component: {fileID: 1392766431}
m_Layer: 0
m_Name: CohortAudioSource
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!82 &1392766431
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1392766430}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!4 &1392766432
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1392766430}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1711676745
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -303,7 +430,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1711676746}
- component: {fileID: 1711676747}
- component: {fileID: 1711676748}
m_Layer: 0
m_Name: CohortManager
m_TagString: Untagged
Expand All @@ -325,7 +452,7 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1711676747
--- !u!114 &1711676748
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -334,6 +461,29 @@ MonoBehaviour:
m_GameObject: {fileID: 1711676745}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cefc399685197493e97d9d819b9d0abc, type: 3}
m_Script: {fileID: 11500000, guid: 202f157f33e844f9796b7a82e6543b08, type: 3}
m_Name:
m_EditorClassIdentifier:
serverURL: localhost
httpPort: 3000
webSocketPath: /sockets
eventId: 7
pushN10nEndpoint:
clientOccasion: 23
clientTag: any
audioPlayer: {fileID: 1392766431}
soundCues:
- audioClip: {fileID: 8300000, guid: b315f72ccd9ab45feb25173f1d7cba9b, type: 3}
cueNumber: 1
accessibleAlternative: '[cat meowing angrily]'
videoPlayer: {fileID: 0}
fullscreenVideoSurface: {fileID: 0}
videoCues: []
nullVideo: {fileID: 0}
textCueArea: {fileID: 0}
textCues: []
flashlightController: {fileID: 0}
groupingUI: []
occasionUI: []
groupingLabel: {fileID: 0}
connectionIndicator: {fileID: 0}
File renamed without changes.
8 changes: 8 additions & 0 deletions Assets/CohortUnityClient/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Assets/CohortUnityClient/Scripts/CHMessage.cs
@@ -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"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9f97c7e

Please sign in to comment.