Skip to content

Commit 264abd7

Browse files
jsm174freezy
authored andcommitted
misc: add alphanumeric support to DisplayUpdateEvent. Add DisplayUpdateEvent icon
1 parent 8a5a9ec commit 264abd7

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Editor/Descriptors/DisplayUpdateEventUnitDescriptor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class DisplayUpdateEventUnitDescriptor : UnitDescriptor<DisplayUpdateEven
2525
{
2626
public DisplayUpdateEventUnitDescriptor(DisplayUpdateEventUnit target) : base(target) { }
2727

28-
protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.UpdateDisplay);
28+
protected override EditorTexture DefinedIcon() => EditorTexture.Single(Unity.Editor.Icons.DisplayUpdateEvent);
2929

3030
protected override void DefinedPort(IUnitPort port, UnitPortDescription desc)
3131
{
@@ -36,6 +36,9 @@ protected override void DefinedPort(IUnitPort port, UnitPortDescription desc)
3636
case nameof(DisplayUpdateEventUnit.NumericOutput):
3737
desc.summary = "The numerical value of the display update.";
3838
break;
39+
case nameof(DisplayUpdateEventUnit.TextOutput):
40+
desc.summary = "The text value of the display update.";
41+
break;
3942
}
4043
}
4144
}

Runtime/Nodes/Display/DisplayUpdateEventUnit.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System;
1818
using System.Collections.Generic;
1919
using System.Collections.ObjectModel;
20+
using System.Text;
2021
using Unity.VisualScripting;
2122
using UnityEngine;
2223

@@ -36,6 +37,10 @@ public class DisplayUpdateEventUnit : GleEventUnit<DisplayUpdateEventArgs>
3637
[PortLabel("Numeric")]
3738
public ValueOutput NumericOutput { get; private set; }
3839

40+
[DoNotSerialize]
41+
[PortLabel("Text")]
42+
public ValueOutput TextOutput { get; private set; }
43+
3944
[DoNotSerialize]
4045
protected override bool register => true;
4146

@@ -46,10 +51,13 @@ protected override void Definition()
4651
base.Definition();
4752

4853
if (Display != null) {
49-
if (Display.Supports(DisplayFrameFormat.Numeric))
50-
{
54+
if (Display.Supports(DisplayFrameFormat.Numeric)) {
5155
NumericOutput = ValueOutput<float>(nameof(NumericOutput));
5256
}
57+
58+
if (Display.Supports(DisplayFrameFormat.AlphaNumeric)) {
59+
TextOutput = ValueOutput<string>(nameof(TextOutput));
60+
}
5361
}
5462
}
5563

@@ -65,6 +73,12 @@ protected override void AssignArguments(Flow flow, DisplayUpdateEventArgs args)
6573
flow.SetValue(NumericOutput, BitConverter.ToSingle(args.DisplayFrameData.Data));
6674
}
6775
}
76+
77+
if (Display.Supports(DisplayFrameFormat.AlphaNumeric)) {
78+
if (args.DisplayFrameData.Format == DisplayFrameFormat.AlphaNumeric) {
79+
flow.SetValue(TextOutput, Encoding.UTF8.GetString(args.DisplayFrameData.Data));
80+
}
81+
}
6882
}
6983
}
7084
}

0 commit comments

Comments
 (0)