diff --git a/Example/ExampleScene.unity b/Example/ExampleScene.unity index 7944e3c..8bb81ca 100644 --- a/Example/ExampleScene.unity +++ b/Example/ExampleScene.unity @@ -112,6 +112,106 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &112402471 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 112402475} + - component: {fileID: 112402474} + - component: {fileID: 112402473} + - component: {fileID: 112402472} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &112402472 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 112402471} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &112402473 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 112402471} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &112402474 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 112402471} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &112402475 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 112402471} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1967446008} + - {fileID: 536789100} + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} --- !u!1 &170076733 GameObject: m_ObjectHideFlags: 0 @@ -181,6 +281,230 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &225066021 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 225066022} + - component: {fileID: 225066024} + - component: {fileID: 225066023} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &225066022 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 225066021} + 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: 989851877} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &225066023 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 225066021} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &225066024 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 225066021} + m_CullTransparentMesh: 0 +--- !u!1 &324107845 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 324107848} + - component: {fileID: 324107847} + - component: {fileID: 324107846} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &324107846 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 324107845} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &324107847 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 324107845} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &324107848 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 324107845} + 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: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &519464478 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 519464479} + - component: {fileID: 519464481} + - component: {fileID: 519464480} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &519464479 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 519464478} + 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: 2017599632} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &519464480 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 519464478} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Send +--- !u!222 &519464481 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 519464478} + m_CullTransparentMesh: 0 --- !u!1 &534669902 GameObject: m_ObjectHideFlags: 0 @@ -263,6 +587,299 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &536789099 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 536789100} + m_Layer: 5 + m_Name: Output + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &536789100 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 536789099} + 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: + - {fileID: 903967842} + m_Father: {fileID: 112402475} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 6, y: 71} + m_SizeDelta: {x: 525, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &884279357 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 884279358} + m_Layer: 5 + m_Name: Input + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &884279358 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 884279357} + 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: + - {fileID: 989851877} + - {fileID: 2017599632} + m_Father: {fileID: 1967446008} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -0.000011444} + m_SizeDelta: {x: 546.2, y: 24.5} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &903967841 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 903967842} + - component: {fileID: 903967844} + - component: {fileID: 903967843} + m_Layer: 5 + m_Name: OutputText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &903967842 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 903967841} + 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: 536789100} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 537.1, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &903967843 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 903967841} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 6 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Output:' +--- !u!222 &903967844 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 903967841} + m_CullTransparentMesh: 0 +--- !u!1 &989851876 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 989851877} + - component: {fileID: 989851880} + - component: {fileID: 989851879} + - component: {fileID: 989851878} + m_Layer: 5 + m_Name: InputField + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &989851877 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 989851876} + 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: + - {fileID: 1719511398} + - {fileID: 225066022} + m_Father: {fileID: 884279358} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -78, y: -2} + m_SizeDelta: {x: 374.5, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &989851878 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 989851876} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 575553740, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 989851879} + m_TextComponent: {fileID: 225066023} + m_Placeholder: {fileID: 1719511399} + m_ContentType: 0 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 0 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 0 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.InputField+SubmitEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 +--- !u!114 &989851879 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 989851876} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &989851880 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 989851876} + m_CullTransparentMesh: 0 --- !u!1 &1568690303 GameObject: m_ObjectHideFlags: 0 @@ -272,9 +889,9 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1568690304} - - component: {fileID: 1568690305} - - component: {fileID: 1568690306} - component: {fileID: 1568690307} + - component: {fileID: 1568690306} + - component: {fileID: 1568690305} m_Layer: 0 m_Name: _Logic m_TagString: Untagged @@ -309,9 +926,12 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: _settings: {fileID: 11400000, guid: 63110a94ecb1d1f4ea073685aeca9cb5, type: 2} - _charisma: {fileID: 1568690306} - _useAudio: 1 + _inputField: {fileID: 989851878} + _button: {fileID: 2017599633} + _outputField: {fileID: 903967843} + _useAudio: 0 _audioSource: {fileID: 1568690307} + _logLevels: 5 --- !u!114 &1568690306 MonoBehaviour: m_ObjectHideFlags: 0 @@ -421,3 +1041,275 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!1 &1719511397 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1719511398} + - component: {fileID: 1719511400} + - component: {fileID: 1719511399} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1719511398 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1719511397} + 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: 989851877} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1719511399 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1719511397} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Enter text... +--- !u!222 &1719511400 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1719511397} + m_CullTransparentMesh: 0 +--- !u!1 &1967446007 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1967446008} + - component: {fileID: 1967446010} + - component: {fileID: 1967446009} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1967446008 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1967446007} + 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: + - {fileID: 884279358} + m_Father: {fileID: 112402475} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 1067, y: 600} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1967446009 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1967446007} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.13207549, g: 0.13207549, b: 0.13207549, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &1967446010 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1967446007} + m_CullTransparentMesh: 0 +--- !u!1 &2017599631 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2017599632} + - component: {fileID: 2017599635} + - component: {fileID: 2017599634} + - component: {fileID: 2017599633} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2017599632 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2017599631} + 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: + - {fileID: 519464479} + m_Father: {fileID: 884279358} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 195, y: -2} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2017599633 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2017599631} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 2017599634} + m_OnClick: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &2017599634 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2017599631} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &2017599635 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2017599631} + m_CullTransparentMesh: 0 diff --git a/Example/ExampleScript.cs b/Example/ExampleScript.cs index 5c4e01f..238223a 100644 --- a/Example/ExampleScript.cs +++ b/Example/ExampleScript.cs @@ -1,54 +1,165 @@ -using BestHTTP.Logger; +using System.Collections.Generic; +using BestHTTP.Logger; using UnityEngine; +using UnityEngine.UI; namespace CharismaSDK.Example { + [RequireComponent(typeof(Charisma))] public class ExampleScript : MonoBehaviour { [Header("Assign charisma settings object here")] [SerializeField] private CharismaSettings _settings; - [SerializeField] private Charisma _charisma; + [SerializeField] private InputField _inputField; + [SerializeField] private Button _button; + [SerializeField] private Text _outputField; [SerializeField] private bool _useAudio; [SerializeField] private AudioSource _audioSource; + + [Header("For advanced debugging")] + [SerializeField] private Loglevels _logLevels; - private CharismaSettings _charismaSettings; + // Reference to the charisma component on this Game Object. + private Charisma _charisma; + + // List of all current conversation. + private Dictionary _conversations; + + #region Monobehaviour Callbacks private void Start() { + _charisma = GetComponent(); + _conversations = new Dictionary(); + + BindEvents(); + + // Entry point. + StartConversation(); + + _inputField.ActivateInputField(); + } - // Get token - _charisma.GetToken(); - _charisma.OnTokenReceived += token => - { - // Use token to add conversation - _charisma.Initialise(token, Loglevels.Error); - _charisma.AddConversation(token); - }; + private void Update() + { + if (!Input.GetKeyDown(KeyCode.Return) || _inputField.text == string.Empty) return; + + SendPlayerMessage(_inputField.text); + _inputField.text = string.Empty; + } - _charisma.OnConversationInitialised += id => - { - // Once a conversation has been added. Connect to Charisma - _charisma.Connect(); - }; + #endregion + + #region Events - _charisma.OnConnected += () => + // Bind all events relevant to communicating with Charisma. + private void BindEvents() + { + _charisma.OnTokenReceived += InitializeCharisma; + _charisma.OnConversationInitialised += Connect; + _charisma.OnConnected += StartInteraction; + _charisma.OnReceivedResponse += HandleResponse; + + _button.onClick.AddListener((() => { - // Once we are connected. Start the interaction - _charisma.StartInteraction(1, _useAudio); + SendPlayerMessage(_inputField.text); + _inputField.text = string.Empty; - }; + })); + } + + private void OnDisable() + { + UnbindEvents(); + StopConversation(); + } - _charisma.OnReceivedResponse += (response, responseAudio, url) => - { - // We have received a response - Debug.Log($"Charisma: {response.Message.Text}"); + private void OnDestroy() + { + UnbindEvents(); + StopConversation(); + } + + private void UnbindEvents() + { + _charisma.OnTokenReceived -= InitializeCharisma; + _charisma.OnConversationInitialised -= Connect; + _charisma.OnConnected -= StartInteraction; + _charisma.OnReceivedResponse -= HandleResponse; + } + + #endregion + + #region Initialisation + + private void StartConversation() + { + // Get token. + _charisma.GetToken(); + } + + private void InitializeCharisma(string token) + { + // Initialise our Charisma object. + _charisma.Initialise(token, _logLevels); + + // Use token to add conversation. + _charisma.AddConversation(token); + } + + private void Connect(int id) + { + // Save conversation + _conversations.Add("MyFirstConversation", new Conversation(id)); + + // Once a conversation has been added. Connect to Charisma. + _charisma.Connect(); + } + + private void StartInteraction() + { + // Once we are connected. Start the interaction. + _charisma.StartInteraction(1, _useAudio); + } + + #endregion + + #region Communication - if (!_useAudio) return; + private void HandleResponse(Response response, AudioClip responseAudio, string url) + { + // We have received a response. + Debug.Log($"Charisma: {response.Message.Text}"); + _outputField.text = $"{response.Message.Character.Name}: {response.Message.Text}"; + + if (!_useAudio) return; - // If we have defined audio, play it now - _audioSource.clip = responseAudio; - _audioSource.Play(); - }; + // If we have defined audio, play it now. + _audioSource.clip = responseAudio; + _audioSource.Play(); + + if (!response.EndStory) return; + + // If the node is marked as "End Story", disconnect. + StopConversation(); + } + + // Send a player message to charisma. Include our audio preferences. + private void SendPlayerMessage(string message) + { + _charisma.SendPlayerMessage(message, _useAudio); + } + + #endregion + + #region Termination + + private void StopConversation() + { + _charisma.Disconnect(); } + + #endregion + } } diff --git a/Scripts/Charisma.cs b/Scripts/Charisma.cs index 84f7a11..91e0385 100644 --- a/Scripts/Charisma.cs +++ b/Scripts/Charisma.cs @@ -176,7 +176,7 @@ private IEnumerator GetConversation(string token) #region Delegates - public delegate void StoryEventDelegate(Response response, AudioClip responseAudio, string audioUrl); + public delegate void StoryEventDelegate(Response response, AudioClip clip, string url); public delegate void CharismaEventDelegate(); public delegate void TokenEventDelegate(string token); public delegate void ConversationEventDelegate(int conversationId); @@ -187,11 +187,30 @@ private IEnumerator GetConversation(string token) #endregion #region Events - + + /// + /// A new response has been received + /// public event StoryEventDelegate OnReceivedResponse; + + /// + /// Successfully connected to the server + /// public event CharismaEventDelegate OnConnected; + + /// + /// Successfully set memory + /// public event CharismaEventDelegate OnMemorySet; + + /// + /// Successfully generated a token + /// public event TokenEventDelegate OnTokenReceived; + + /// + /// Successfully initialised a conversation + /// public event ConversationEventDelegate OnConversationInitialised; #endregion @@ -327,12 +346,18 @@ public void Connect() } else { - // TODO: Move to task based system ExecuteOnMainThread.Enqueue(() => { StartCoroutine(GenerateAudio(Response)); }); } + else + { + ExecuteOnMainThread.Enqueue(() => + { + SendReceivedResponse(); + }); + } // We are done processing this response _isProcessing = false; @@ -436,7 +461,7 @@ public void StartInteraction(int sceneIndex, bool speech, Conversation conversat /// - /// Send a tap event to Charisma + /// Send a tap event to Charisma. /// public void Tap() { @@ -449,13 +474,53 @@ public void Tap() var tapOptions = new TapOptions(Conversation, SpeechOptions); _socket?.Emit("tap", tapOptions); - //Debug.Log("Charisma: Tap"); + if(_showLog) + Debug.Log("Charisma: Tap"); + } + + /// + /// Send a tap event to Charisma. + /// + /// Set true if the next response should contain speech + public void Tap(bool speech) + { + if (_socket == null) + { + Debug.LogError("Charisma: Socket not open. Connect before sending commands"); + return; + }; + + var tapOptions = speech ? new TapOptions(Conversation, SpeechOptions) : new TapOptions(Conversation); + _socket?.Emit("tap", tapOptions); + + if(_showLog) + Debug.Log("Charisma: Tap"); } /// - /// Set a memory in Charisma + /// Send a tap event to Charisma. /// - /// The memory to be set. Needs to have the same Key as the corresponding memory in Charisma + /// Set true if the next response should contain speech. + /// Conversation to sent tap to. + public void Tap(bool speech, Conversation conversation) + { + if (_socket == null) + { + Debug.LogError("Charisma: Socket not open. Connect before sending commands"); + return; + }; + + var tapOptions = speech ? new TapOptions(conversation, SpeechOptions) : new TapOptions(conversation); + _socket?.Emit("tap", tapOptions); + + if(_showLog) + Debug.Log("Charisma: Tap"); + } + + /// + /// Set a memory in Charisma. + /// + /// The memory to be set. Needs to have the same Key as the corresponding memory in Charisma. public void SetMemory(Memory memory) { StartCoroutine(AttemptSetMemory(memory)); @@ -479,8 +544,6 @@ private IEnumerator AttemptSetMemory(Memory memory) request.UseAlternateSSL = true; request.Send(); - - while (request.State != HTTPRequestStates.Finished) yield return null; @@ -490,24 +553,21 @@ private IEnumerator AttemptSetMemory(Memory memory) OnMemorySet?.Invoke(); } else - Debug.Log(request.Exception); - + Debug.Log(request.Exception); } - - + /// /// Set mood in Charisma. /// public void SetMood() { - // TODO: Move to post request - + // TODO: Move to post request } /// - /// Send player message to Charisma + /// Send player message with speech to Charisma /// - /// + /// Message to send public void SendPlayerMessage(string message) { if (_socket == null) @@ -525,15 +585,16 @@ public void SendPlayerMessage(string message) var playerMessage = new PlayerMessage(message, SpeechOptions, Conversation.conversationId); _socket?.Emit("reply", playerMessage); - //Debug.Log("Charisma: Sending player message"); + if(_showLog) + Debug.Log("Charisma: Sending player message"); } /// /// Send player message to Charisma /// - /// - /// - public void SendPlayerMessage(string message, Conversation conversation) + /// Message to send + /// Set true if the next response should contain speech + public void SendPlayerMessage(string message, bool speech) { if (_socket == null) { @@ -546,23 +607,55 @@ public void SendPlayerMessage(string message, Conversation conversation) Debug.LogWarning("Charisma: Cannot send player message when Charisma is processing"); return; } - - var playerMessage = new PlayerMessage(message, SpeechOptions, conversation.conversationId); - _socket?.Emit("reply", playerMessage); - - //Debug.Log("Charisma: Sending player message"); + + var playerMessage = speech + ? new PlayerMessage(message, SpeechOptions, Conversation.conversationId) + : new PlayerMessage(message, Conversation.conversationId); + _socket?.Emit("reply", playerMessage); + + if(_showLog) + Debug.Log("Charisma: Sending player message"); + } + + /// + /// Send player message to Charisma + /// + /// Message to send + /// Set true if the next response should contain speech + /// Conversation to interact with + public void SendPlayerMessage(string message, bool speech, Conversation conversation) + { + if (_socket == null) + { + Debug.LogError("Charisma: Socket not open. Connect before sending player message"); + return; + }; + + if (_isProcessing) + { + Debug.LogWarning("Charisma: Cannot send player message when Charisma is processing"); + return; + } + + var playerMessage = speech + ? new PlayerMessage(message, SpeechOptions, conversation.conversationId) + : new PlayerMessage(message, conversation.conversationId); + _socket?.Emit("reply", playerMessage); + + if(_showLog) + Debug.Log("Charisma: Sending player message"); } #endregion #region Audio - // Generate Audio private IEnumerator GenerateAudio(Response response) { if (SpeechOptions.encoding == "mp3") { - Debug.Log("Charisma: Generating audio"); + if(_showLog) + Debug.Log("Charisma: Generating audio"); var tempFile = Application.persistentDataPath + "/bytes.mp3"; @@ -582,7 +675,8 @@ private IEnumerator GenerateAudio(Response response) } else { - Debug.Log("Charisma: Generating audio"); + if(_showLog) + Debug.Log("Charisma: Generating audio"); var tempFile = Application.persistentDataPath + "/bytes.ogg"; @@ -607,16 +701,16 @@ private IEnumerator GenerateAudio(Response response) #region Termination private void OnApplicationQuit() - { - if (_socket == null) return; - if (_socketManager == null) return; - + { Disconnect(); } - // Disconnect from the current interaction + // Disconnect from the current interaction. public void Disconnect() { + if (_socket == null) return; + if (_socketManager == null) return; + try { _socket.Disconnect(); diff --git a/Scripts/CharismaUtilities.cs b/Scripts/CharismaUtilities.cs index c852cd3..8630405 100644 --- a/Scripts/CharismaUtilities.cs +++ b/Scripts/CharismaUtilities.cs @@ -44,7 +44,7 @@ private static MemoryStream AudioMemStream(WaveStream waveStream) #endregion /// - /// Convert token response to token + /// Convert token response to token. /// /// JSON payload /// @@ -88,7 +88,7 @@ public static string ConversationToJson(Conversation conversation) } /// - /// Generate a Charisma response from the response string + /// Generate a Charisma response from the response string. /// /// JSON payload /// @@ -99,7 +99,7 @@ public static Response GenerateResponse(string charismaResponse) } /// - /// Convert a memory to Json + /// Convert a memory to Json. /// /// public static string MemoryToJson(Memory memory) diff --git a/Scripts/Conversation.cs b/Scripts/Conversation.cs index b72ead1..0ac3401 100644 --- a/Scripts/Conversation.cs +++ b/Scripts/Conversation.cs @@ -1,8 +1,11 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace CharismaSDK -{ public class Conversation +{ + /// + /// Instance of a conversation. + /// + public class Conversation { public int conversationId; diff --git a/Scripts/ConversationResponseParams.cs b/Scripts/ConversationResponseParams.cs index ebefa95..919c709 100644 --- a/Scripts/ConversationResponseParams.cs +++ b/Scripts/ConversationResponseParams.cs @@ -4,6 +4,9 @@ namespace CharismaSDK { public class ConversationResponseParams { + /// + /// The id of the conversation we have just initialized. + /// public int ConversationId { get; } [JsonConstructor] diff --git a/Scripts/Emotions.cs b/Scripts/Emotions.cs index 20d884b..1eb2d94 100644 --- a/Scripts/Emotions.cs +++ b/Scripts/Emotions.cs @@ -3,6 +3,9 @@ namespace CharismaSDK { + /// + /// The current emotions of this character + /// public class Emotions { [Header("Low = sad, High = happy")] diff --git a/Scripts/PlayerMessage.cs b/Scripts/PlayerMessage.cs index 8cb4c0d..d36791e 100644 --- a/Scripts/PlayerMessage.cs +++ b/Scripts/PlayerMessage.cs @@ -1,10 +1,10 @@ namespace CharismaSDK -{ +{ public class PlayerMessage { public int conversationId { get; } public string text { get; } - public SpeechStartOptions speechConfig { get; set; } + public SpeechStartOptions speechConfig { get; } public PlayerMessage(string text, SpeechStartOptions speechConfig, int conversationId) { @@ -12,5 +12,12 @@ public PlayerMessage(string text, SpeechStartOptions speechConfig, int conversat this.speechConfig = speechConfig; this.conversationId = conversationId; } + + public PlayerMessage(string text, int conversationId) + { + this.text = text; + this.speechConfig = null; + this.conversationId = conversationId; + } } } \ No newline at end of file diff --git a/Scripts/Response.cs b/Scripts/Response.cs index c685d17..cb8952f 100644 --- a/Scripts/Response.cs +++ b/Scripts/Response.cs @@ -1,5 +1,4 @@ -using CharismaPlugin; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace CharismaSDK { @@ -12,10 +11,8 @@ public enum CharismaMessageType public class Response { /// - /// - Object returned from charisma. - /// - Has to be deserialized from Json before being read. + /// Response generated by Charisma. /// - [JsonConstructor] public Response(int conversationId, CharismaMessageType messageType, ResponseMessage message, bool endStory, bool tapToContinue, CharacterMood[] characterMoods, Memory[] memories) { @@ -28,12 +25,39 @@ public Response(int conversationId, CharismaMessageType messageType, ResponseMes this.Memories = memories; } + /// + /// The conversation id of the response. + /// public int ConversationId { get; } + + /// + /// The type of this message. + /// public CharismaMessageType CharismaMessageType { get; } + + /// + /// Contents of the message. + /// public ResponseMessage Message { get; } + + /// + /// True if the node this response was generated from has "End Story" activated. + /// public bool EndStory { get; } + + /// + /// True if the node this response was generate from has "Tap To Continue" activated. + /// public bool TapToContinue { get; } + + /// + /// List of character moods which has changed on this node. + /// public CharacterMood[] CharacterMoods { get; } + + /// + /// List of memories which has changed since the last character node. + /// public Memory[] Memories { get; } } } diff --git a/Scripts/ResponseMessage.cs b/Scripts/ResponseMessage.cs index b89aa7f..5c154c0 100644 --- a/Scripts/ResponseMessage.cs +++ b/Scripts/ResponseMessage.cs @@ -5,7 +5,7 @@ namespace CharismaSDK { /// - /// - Contains data related to a characters response such as, text, audio etc. + /// Contains data related to a characters response such as, text, audio etc. /// public class ResponseMessage { @@ -19,9 +19,24 @@ public ResponseMessage(string text, Character character, Speech speech, this.Metadata = metadata; } + /// + /// The text of the response. + /// public string Text { get; } + + /// + /// The character that spoke / said something. + /// public Character Character { get; } + + /// + /// The audio information generated by the speech on this node + /// public Speech Speech { get; } + + /// + /// Metadata attached to this node. + /// public Dictionary Metadata { get; } } } diff --git a/Scripts/TapOptions.cs b/Scripts/TapOptions.cs index 77c9108..457c7a8 100644 --- a/Scripts/TapOptions.cs +++ b/Scripts/TapOptions.cs @@ -10,5 +10,11 @@ public TapOptions(Conversation conversation, SpeechStartOptions speechConfig) this.conversationId = conversation.ConversationId; this.speechConfig = speechConfig; } + + public TapOptions(Conversation conversation) + { + this.conversationId = conversation.ConversationId; + this.speechConfig = null; + } } }