Skip to content

Commit 45585fe

Browse files
committed
feat(new node): note nodes can now be added to graphs
Also includes an overhaul of dark and light mode theme displays. Some of the displays were completely broken due to changes to Unity's UI system
1 parent 09e8596 commit 45585fe

21 files changed

+482
-159
lines changed

Assets/Examples/BasicConversation/ExampleConversation.asset

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ MonoBehaviour:
1515
_uniqueId: 0eacc16b-09da-4963-bd52-a0f523d2eaae
1616
rect:
1717
serializedVersion: 2
18-
x: 51260
19-
y: 50235
18+
x: 51272
19+
y: 50247
2020
width: 200
21-
height: 142
21+
height: 146
2222
nodeTitle:
2323
children:
2424
- {fileID: 8469888643324881027}
@@ -62,7 +62,7 @@ MonoBehaviour:
6262
x: 50972
6363
y: 50397
6464
width: 200
65-
height: 142
65+
height: 146
6666
nodeTitle:
6767
children:
6868
- {fileID: -9183305000158909614}
@@ -92,7 +92,7 @@ MonoBehaviour:
9292
x: 51819
9393
y: 50359
9494
width: 200
95-
height: 142
95+
height: 146
9696
nodeTitle:
9797
children:
9898
- {fileID: -3436942782412272395}
@@ -136,7 +136,7 @@ MonoBehaviour:
136136
x: 51819
137137
y: 50507
138138
width: 200
139-
height: 142
139+
height: 146
140140
nodeTitle:
141141
children:
142142
- {fileID: -1807495471838374980}
@@ -195,10 +195,10 @@ MonoBehaviour:
195195
_uniqueId: 9b8bf58c-0906-4ca9-a722-d589abfb87c3
196196
rect:
197197
serializedVersion: 2
198-
x: 50700
199-
y: 50156
198+
x: 50715
199+
y: 50151
200200
width: 200
201-
height: 222
201+
height: 226
202202
nodeTitle:
203203
children: []
204204
conditions: []
@@ -232,7 +232,7 @@ MonoBehaviour:
232232
x: 52270
233233
y: 50209
234234
width: 200
235-
height: 142
235+
height: 146
236236
nodeTitle:
237237
children:
238238
- {fileID: -1807495471838374980}
@@ -293,7 +293,7 @@ MonoBehaviour:
293293
x: 52043
294294
y: 50360
295295
width: 200
296-
height: 142
296+
height: 146
297297
nodeTitle:
298298
children:
299299
- {fileID: -1807495471838374980}
@@ -322,7 +322,7 @@ MonoBehaviour:
322322
x: 50976
323323
y: 50078
324324
width: 200
325-
height: 142
325+
height: 146
326326
nodeTitle:
327327
children:
328328
- {fileID: -9183305000158909614}
@@ -352,6 +352,31 @@ MonoBehaviour:
352352
children:
353353
- {fileID: 2969575773676471478}
354354
_uniqueId: e9aad9c8-491b-4bb2-8665-6fc4cde30c9b
355+
--- !u!114 &-2030564491796885544
356+
MonoBehaviour:
357+
m_ObjectHideFlags: 0
358+
m_CorrespondingSourceObject: {fileID: 0}
359+
m_PrefabInstance: {fileID: 0}
360+
m_PrefabAsset: {fileID: 0}
361+
m_GameObject: {fileID: 0}
362+
m_Enabled: 1
363+
m_EditorHideFlags: 0
364+
m_Script: {fileID: 11500000, guid: 9bde9a25e35e47d5bc8e840897ea28e6, type: 3}
365+
m_Name: Note
366+
m_EditorClassIdentifier:
367+
_uniqueId: 99fb440c-334f-4912-bd1f-2c97f48b7430
368+
rect:
369+
serializedVersion: 2
370+
x: 50464.33
371+
y: 50344.004
372+
width: 200
373+
height: 106
374+
nodeTitle:
375+
children: []
376+
conditions: []
377+
enterActions: []
378+
exitActions: []
379+
note: This is a note I left behind
355380
--- !u!114 &-1807495471838374980
356381
MonoBehaviour:
357382
m_ObjectHideFlags: 0
@@ -410,7 +435,7 @@ MonoBehaviour:
410435
x: 52048
411436
y: 50211
412437
width: 200
413-
height: 142
438+
height: 146
414439
nodeTitle:
415440
children:
416441
- {fileID: -5972268922082454213}
@@ -495,8 +520,9 @@ MonoBehaviour:
495520
- {fileID: -7347677369531188231}
496521
- {fileID: -1221359623688907011}
497522
- {fileID: 3721123120546049034}
523+
- {fileID: -2030564491796885544}
498524
root: {fileID: 426936237664981933}
499-
scrollPosition: {x: 50048.676, y: 50061}
525+
scrollPosition: {x: 49863.336, y: 49924.336}
500526
--- !u!114 &373158185418196577
501527
MonoBehaviour:
502528
m_ObjectHideFlags: 0
@@ -515,7 +541,7 @@ MonoBehaviour:
515541
x: 50467
516542
y: 50163
517543
width: 200
518-
height: 142
544+
height: 146
519545
nodeTitle:
520546
children:
521547
- {fileID: -6450186612614065154}
@@ -541,8 +567,8 @@ MonoBehaviour:
541567
_uniqueId: cd458853-4898-4aa5-a8cc-cb7b6dce03b1
542568
rect:
543569
serializedVersion: 2
544-
x: 50050
545-
y: 50200
570+
x: 50010
571+
y: 50197.33
546572
width: 100
547573
height: 57
548574
nodeTitle:
@@ -569,7 +595,7 @@ MonoBehaviour:
569595
x: 50978
570596
y: 50237
571597
width: 200
572-
height: 142
598+
height: 146
573599
nodeTitle:
574600
children:
575601
- {fileID: -9183305000158909614}
@@ -599,7 +625,7 @@ MonoBehaviour:
599625
x: 51229
600626
y: 50544
601627
width: 200
602-
height: 142
628+
height: 146
603629
nodeTitle:
604630
children:
605631
- {fileID: -6450186612614065154}
@@ -644,7 +670,7 @@ MonoBehaviour:
644670
x: 51561
645671
y: 50151
646672
width: 200
647-
height: 142
673+
height: 146
648674
nodeTitle:
649675
children:
650676
- {fileID: 8469888643324881027}
@@ -738,7 +764,7 @@ MonoBehaviour:
738764
x: 51822
739765
y: 50209
740766
width: 200
741-
height: 142
767+
height: 146
742768
nodeTitle:
743769
children:
744770
- {fileID: -1590606014626862060}
@@ -793,10 +819,10 @@ MonoBehaviour:
793819
_uniqueId: e89a7a34-92ab-4b6d-be12-57808bba2c05
794820
rect:
795821
serializedVersion: 2
796-
x: 50219
797-
y: 50170
822+
x: 50215.664
823+
y: 50153.332
798824
width: 200
799-
height: 142
825+
height: 146
800826
nodeTitle:
801827
children:
802828
- {fileID: 373158185418196577}

Assets/com.fluid.dialogue/Editor/Inspectors/NodeDataBase/NodeDataBaseEditor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ private void OnEnable () {
2020
_dialogue = serializedObject.FindProperty("dialogue");
2121
_choices = serializedObject.FindProperty("choices");
2222

23-
_conditions = new ConditionSortableList(this, "conditions", node, node.conditions);
23+
if (!node.HideInspectorConditions)
24+
_conditions = new ConditionSortableList(this, "conditions", node, node.conditions);
25+
2426
if (!node.HideInspectorActions) {
2527
_enterActions = new ActionsSortableList(this, "enterActions", node, node.enterActions);
2628
_exitActions = new ActionsSortableList(this, "exitActions", node, node.exitActions);
@@ -33,7 +35,7 @@ public override void OnInspectorGUI () {
3335

3436
serializedObject.Update();
3537

36-
_conditions.Update();
38+
_conditions?.Update();
3739
_enterActions?.Update();
3840
_exitActions?.Update();
3941

Assets/com.fluid.dialogue/Editor/NodeEditors/Base/HeaderTextStyle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public GUIStyle Style {
1111
if (!_init && EditorStyles.centeredGreyMiniLabel != null) {
1212
_init = true;
1313
_style = EditorStyles.centeredGreyMiniLabel;
14-
_style.normal.textColor = Color.black;
14+
_style.normal.textColor = ThemeUtility.IsDarkTheme ? Color.white : Color.black;
1515
} else if (_style == null) {
1616
_style = new GUIStyle();
1717
}

Assets/com.fluid.dialogue/Editor/NodeEditors/Base/NodeEditorBase.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public abstract partial class NodeEditorBase {
2222
public NodeDataBase Data { get; private set; }
2323
private bool IsSelected { get; set; }
2424

25-
protected virtual Color NodeColor => Color.gray;
25+
protected virtual Color NodeColor { get; } = new Color(0.7f, 0.7f, 0.7f);
2626
protected virtual float NodeWidth { get; } = 100;
2727

2828
public bool IsMemoryLeak => Data == null;
@@ -57,11 +57,7 @@ public void Print () {
5757
PrintBody();
5858
}
5959

60-
if (IsSelected) {
61-
GUI.Box(Data.rect, GUIContent.none, _styles.ContainerHighlightStyle.Style);
62-
}
63-
64-
PrintConnections();
60+
if (!Data.HideConnections) PrintConnections();
6561
}
6662

6763
private void PrintHeader () {
@@ -72,7 +68,11 @@ private void PrintHeader () {
7268
headerBox.width - PADDING_HEADER,
7369
headerBox.height - PADDING_HEADER);
7470

71+
var prev = GUI.backgroundColor;
72+
GUI.backgroundColor = _styles.BodyColor;
7573
GUI.Box(headerBox, GUIContent.none, _styles.HeaderStyle.Style);
74+
GUI.backgroundColor = prev;
75+
7676
GUI.Label(headerArea, NodeTitle, _styles.HeaderTextStyle.Style);
7777
}
7878

@@ -84,7 +84,14 @@ private void PrintBody () {
8484
Data.rect.width - PADDING_CONTENT,
8585
Data.rect.height - PADDING_CONTENT);
8686

87-
GUI.Box(box, GUIContent.none, _styles.ContentStyle.Style);
87+
var prev = GUI.backgroundColor;
88+
GUI.backgroundColor = _styles.BodyColor;
89+
if (IsSelected) {
90+
GUI.Box(box, GUIContent.none, _styles.ContainerHighlightStyle.Style);
91+
} else {
92+
GUI.Box(box, GUIContent.none, _styles.ContentStyle.Style);
93+
}
94+
GUI.backgroundColor = prev;
8895

8996
GUILayout.BeginArea(ContentArea);
9097

Assets/com.fluid.dialogue/Editor/NodeEditors/Base/NodeStyles.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ public class NodeStyles {
66
public NodeBoxStyle HeaderStyle { get; }
77
public NodeBoxStyle ContainerHighlightStyle { get; }
88
public HeaderTextStyle HeaderTextStyle { get; }
9+
public Color BodyColor { get; }
910

1011
public NodeStyles (Color bodyColor) {
11-
ContentStyle = new NodeBoxStyle(bodyColor, bodyColor);
12-
ContainerHighlightStyle = new NodeBoxStyle(Color.white, Color.clear);
12+
BodyColor = bodyColor;
13+
14+
ContentStyle = new NodeBoxStyle(BodyColor, BodyColor);
15+
var brightBodyColor = BodyColor * 1.3f;
16+
ContainerHighlightStyle = new NodeBoxStyle(Color.black, brightBodyColor);
1317
HeaderTextStyle = new HeaderTextStyle();
1418

15-
var headerColor = bodyColor * 1.3f;
19+
var headerColor = BodyColor * 1.3f;
1620
headerColor.a = 1f;
1721
HeaderStyle = new NodeBoxStyle(headerColor, headerColor);
1822
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using CleverCrow.Fluid.Dialogues.Nodes;
2+
using UnityEditor;
3+
using UnityEngine;
4+
5+
namespace CleverCrow.Fluid.Dialogues.Editors.NodeDisplays {
6+
[NodeType(typeof(NodeNoteData))]
7+
public class NoteEditor : NodeEditorBase {
8+
protected override Color NodeColor { get; } = Color.yellow;
9+
protected override float NodeWidth { get; } = 200;
10+
11+
protected override void OnPrintBody (Event e) {
12+
serializedObject.Update();
13+
EditorGUILayout.PropertyField(serializedObject.FindProperty("note"), GUIContent.none);
14+
serializedObject.ApplyModifiedProperties();
15+
}
16+
17+
}
18+
}

Assets/com.fluid.dialogue/Editor/NodeEditors/NoteEditor.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/com.fluid.dialogue/Editor/Utilities/NodeBoxStyle.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace CleverCrow.Fluid.Dialogues.Editors {
55
public class NodeBoxStyle {
66
private GUIStyle _style;
7-
private readonly Color32 _borderColor;
7+
private readonly Color _borderColor;
88
private readonly Color _backgroundColor;
99

1010
private Texture2D _texture;
@@ -39,9 +39,17 @@ public NodeBoxStyle (Color32 border, Color background) {
3939
}
4040

4141
private void CreateTexture () {
42-
_texture = Texture2DExtensions.CreateTexture(19, 19, _borderColor);
43-
_texture.SetPixels(1, 1, 17, 17,
44-
Enumerable.Repeat(_backgroundColor, 17 * 17).ToArray());
42+
_texture = new Texture2D(19, 19, TextureFormat.ARGB32, false);
43+
_texture.filterMode = FilterMode.Point;
44+
45+
// Create an array for border colors with semi-transparency
46+
Color[] borderColors = Enumerable.Repeat(new Color(_borderColor.r, _borderColor.g, _borderColor.b, 128), 19 * 19).ToArray();
47+
_texture.SetPixels(borderColors);
48+
49+
// Set the internal area to a transparent background color
50+
Color[] backgroundColors = Enumerable.Repeat(new Color(_backgroundColor.r, _backgroundColor.g, _backgroundColor.b, 0.5f), 17 * 17).ToArray();
51+
_texture.SetPixels(1, 1, 17, 17, backgroundColors);
52+
4553
_texture.Apply();
4654
}
4755
}

Assets/com.fluid.dialogue/Editor/Utilities/Texture2DExtensions.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

Assets/com.fluid.dialogue/Editor/Utilities/Texture2DExtensions.cs.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using UnityEditor;
2+
3+
namespace CleverCrow.Fluid.Dialogues.Editors {
4+
public static class ThemeUtility {
5+
public static bool IsDarkTheme => EditorGUIUtility.isProSkin;
6+
}
7+
}

Assets/com.fluid.dialogue/Editor/Utilities/ThemeUtility.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)