Skip to content

Commit

Permalink
feat: dialogue graphs now support scene objects
Browse files Browse the repository at this point in the history
You can now pass a list of GameObject(s) into `Play` and use them in your graph through the variable
system. Also includes a new SetActive GameObject action example to get you started with writing your
own actions. See the example folder in Assets for full details.
  • Loading branch information
ashblue committed Mar 28, 2020
1 parent 20fe8f1 commit cf78ea2
Show file tree
Hide file tree
Showing 35 changed files with 614 additions and 212 deletions.
112 changes: 93 additions & 19 deletions Assets/Examples/BasicConversation/BasicConversation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ LightmapSettings:
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
Expand Down Expand Up @@ -165,7 +166,7 @@ MonoBehaviour:
m_GameObject: {fileID: 8172350}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1297475563, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
Expand Down Expand Up @@ -227,7 +228,7 @@ MonoBehaviour:
m_GameObject: {fileID: 62754275}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
Expand All @@ -236,8 +237,6 @@ MonoBehaviour:
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: 21300000, guid: b70a0e76870eda6488865d4588137313, type: 3}
m_Type: 3
m_PreserveAspect: 1
Expand All @@ -247,6 +246,7 @@ MonoBehaviour:
m_FillClockwise: 0
m_FillOrigin: 3
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &62754278
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -280,8 +280,9 @@ Light:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 9
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
Expand Down Expand Up @@ -475,7 +476,7 @@ MonoBehaviour:
m_GameObject: {fileID: 991365858}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
Expand All @@ -484,8 +485,6 @@ MonoBehaviour:
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
Expand Down Expand Up @@ -536,7 +535,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1037096122}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
Expand All @@ -553,7 +552,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1037096122}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 1
Expand Down Expand Up @@ -600,6 +599,7 @@ RectTransform:
m_Children:
- {fileID: 2077554727}
- {fileID: 1854390184}
- {fileID: 1217128673}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand All @@ -608,6 +608,79 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1217128672
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1217128673}
- component: {fileID: 1217128675}
- component: {fileID: 1217128674}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1217128673
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1217128672}
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: 1037096126}
m_RootOrder: 2
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: 485.1, y: 261.1}
m_SizeDelta: {x: 31.9, y: 31.9}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1217128674
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1217128672}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0.99777555, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
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
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1217128675
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1217128672}
m_CullTransparentMesh: 0
--- !u!1 &1578604058
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -635,7 +708,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1578604058}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
Expand All @@ -654,7 +727,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1578604058}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
Expand Down Expand Up @@ -741,6 +814,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
dialogue: {fileID: 11400000, guid: 9ee08f7122b445246ba6e627bb67b59a, type: 2}
gameObjectOverrides:
- _variable: {fileID: 11400000, guid: 9f63ecc07e0124045b2c27d0dfb67d38, type: 2}
_gameObject: {fileID: 1217128672}
speakerContainer: {fileID: 1854390183}
portrait: {fileID: 62754277}
lines: {fileID: 991365860}
Expand Down Expand Up @@ -809,7 +885,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1987331375}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
Expand All @@ -818,8 +894,6 @@ MonoBehaviour:
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: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
Expand All @@ -829,6 +903,7 @@ MonoBehaviour:
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1987331378
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -883,7 +958,7 @@ MonoBehaviour:
m_GameObject: {fileID: 2077554726}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
Expand All @@ -892,8 +967,6 @@ MonoBehaviour:
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
Expand All @@ -903,6 +976,7 @@ MonoBehaviour:
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &2077554729
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down
21 changes: 19 additions & 2 deletions Assets/Examples/BasicConversation/ExampleConversation.asset
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ MonoBehaviour:
nodeTitle:
children: []
conditions: []
enterActions: []
enterActions:
- {fileID: 6437907874617121193}
exitActions: []
choices:
- {fileID: -6868820908879997394}
Expand Down Expand Up @@ -469,7 +470,7 @@ MonoBehaviour:
- {fileID: -1221359623688907011}
- {fileID: 3721123120546049034}
root: {fileID: 426936237664981933}
scrollPosition: {x: 51159.676, y: 50096}
scrollPosition: {x: 50450.676, y: 49996}
--- !u!114 &373158185418196577
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -673,6 +674,22 @@ MonoBehaviour:
children:
- {fileID: -1221359623688907011}
_uniqueId: b6639707-3558-459c-b2e0-01ebc3bc951b
--- !u!114 &6437907874617121193
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: df570d683f114d44abe229f3daba4dbb, type: 3}
m_Name: SetActive
m_EditorClassIdentifier:
_title: SetActive
_uniqueId: b63a213c-b0fa-4526-a78b-55ced115098d
_gameObject: {fileID: 11400000, guid: 9f63ecc07e0124045b2c27d0dfb67d38, type: 2}
_setActive: 0
--- !u!114 &6784819468853313292
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System.Linq;
using CleverCrow.Fluid.Databases;
using CleverCrow.Fluid.Dialogues.Graphs;
using UnityEngine;
Expand All @@ -10,6 +11,8 @@ public class ExampleDialoguePlayback : MonoBehaviour {

public DialogueGraph dialogue;

public GameObjectOverride[] gameObjectOverrides;

[Header("Graphics")]
public GameObject speakerContainer;
public Image portrait;
Expand All @@ -19,7 +22,7 @@ public class ExampleDialoguePlayback : MonoBehaviour {
public ChoiceButton choicePrefab;

private void Awake () {
var database = new DatabaseInstance();
var database = new DatabaseInstanceExtended();
_ctrl = new DialogueController(database);

_ctrl.Events.Speak.AddListener((actor, text) => {
Expand Down Expand Up @@ -50,7 +53,7 @@ private void Awake () {
Debug.Log($"Node Enter: {node.GetType()} - {node.UniqueId}");
});

_ctrl.Play(dialogue);
_ctrl.Play(dialogue, gameObjectOverrides.ToArray<IGameObjectOverride>());
}

private void ClearChoices () {
Expand Down
8 changes: 8 additions & 0 deletions Assets/Examples/BasicConversation/Variables.meta

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

16 changes: 16 additions & 0 deletions Assets/Examples/BasicConversation/Variables/VariableImage.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 20133dd9a8004ec68e82b7a342deb715, type: 3}
m_Name: VariableImage
m_EditorClassIdentifier:
key: Initial Background
defaultValue: {fileID: 0}

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

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

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

Loading

0 comments on commit cf78ea2

Please sign in to comment.