From 952fabd5d5c2edce2d55ecc53724fc4f9aa07d37 Mon Sep 17 00:00:00 2001 From: u-Kotovsky Date: Tue, 14 Oct 2025 21:27:58 +0300 Subject: [PATCH 1/4] Implement Simple RemapOnDemand --- .../Generators/GeneratorRemapOnDemand.cs | 78 +++++++++++++++++++ .../Generators/GeneratorRemapOnDemand.cs.meta | 2 + 2 files changed, 80 insertions(+) create mode 100644 Assets/Plugin/Generators/GeneratorRemapOnDemand.cs create mode 100644 Assets/Plugin/Generators/GeneratorRemapOnDemand.cs.meta diff --git a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs new file mode 100644 index 0000000..08a3d52 --- /dev/null +++ b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; +using TMPro; +using UnityEngine; + +public class RemapOnDemand : IDMXGenerator +{ + public DMXChannel ToggleChannel = 0; + public DMXChannel RemapFromChannelStart = 0; + public DMXChannel RemapToChannelStart = 0; + public EquationNumber RemapChannelLength = 0; + public EquationNumber ActivationThreshold = 127; + + public void Construct() { } + public void Deconstruct() { } + public void GenerateDMX(ref List dmxData) + { + //ensure capacity + dmxData.EnsureCapacity(RemapToChannelStart + (int)RemapChannelLength); + dmxData.EnsureCapacity(RemapFromChannelStart + (int)RemapChannelLength); + + if (dmxData[ToggleChannel] > ActivationThreshold) + { + //copy the source channels to the target channel + for (int i = 0; i < RemapChannelLength; i++) + { + dmxData[RemapToChannelStart + i] = dmxData[RemapFromChannelStart + i]; + } + } + } + + private protected TMP_InputField toggleChannelInputfield; + private protected TMP_InputField remapFromChannelStartInputfield; + private protected TMP_InputField remapToChannelStartInputfield; + private protected TMP_InputField remapChannelLengthInputfield; + private protected TMP_InputField activationThresholdInputfield; + + public void ConstructUserInterface(RectTransform rect) + { + toggleChannelInputfield = Util.AddInputField(rect, "Toggle Channel"); + toggleChannelInputfield.text = ToggleChannel.ToString(); + toggleChannelInputfield.onEndEdit.AddListener((value) => + { + ToggleChannel = value; + }); + + remapFromChannelStartInputfield = Util.AddInputField(rect, "Remap From Channel Start"); + remapFromChannelStartInputfield.text = RemapFromChannelStart.ToString(); + remapFromChannelStartInputfield.onEndEdit.AddListener((value) => + { + RemapFromChannelStart = value; + }); + + remapToChannelStartInputfield = Util.AddInputField(rect, "Remap To Channel Start"); + remapToChannelStartInputfield.text = RemapToChannelStart.ToString(); + remapToChannelStartInputfield.onEndEdit.AddListener((value) => + { + RemapToChannelStart = value; + }); + + remapChannelLengthInputfield = Util.AddInputField(rect, "Remap Channel Length"); + remapChannelLengthInputfield.text = RemapChannelLength.ToString(); + remapChannelLengthInputfield.onEndEdit.AddListener((value) => + { + RemapChannelLength = value; + }); + + activationThresholdInputfield = Util.AddInputField(rect, "Activation Threshold"); + activationThresholdInputfield.text = ActivationThreshold.ToString(); + activationThresholdInputfield.onEndEdit.AddListener((value) => + { + ActivationThreshold = value; + }); + } + + public void DeconstructUserInterface() { } + public void UpdateUserInterface() { } + +} diff --git a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs.meta b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs.meta new file mode 100644 index 0000000..8a8302d --- /dev/null +++ b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0644703231acd024bbd4414a27a67bda From b43389d76b139d16ac0e3687f019d7a07ed2313c Mon Sep 17 00:00:00 2001 From: u-Kotovsky Date: Wed, 19 Nov 2025 15:21:52 +0300 Subject: [PATCH 2/4] Use WriteToListAtPosition instead of an for loop --- Assets/Plugin/Generators/GeneratorRemapOnDemand.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs index 08a3d52..4dd4c55 100644 --- a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs +++ b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs @@ -14,17 +14,9 @@ public void Construct() { } public void Deconstruct() { } public void GenerateDMX(ref List dmxData) { - //ensure capacity - dmxData.EnsureCapacity(RemapToChannelStart + (int)RemapChannelLength); - dmxData.EnsureCapacity(RemapFromChannelStart + (int)RemapChannelLength); - if (dmxData[ToggleChannel] > ActivationThreshold) { - //copy the source channels to the target channel - for (int i = 0; i < RemapChannelLength; i++) - { - dmxData[RemapToChannelStart + i] = dmxData[RemapFromChannelStart + i]; - } + dmxData.WriteToListAtPosition(dmxData.GetRange(RemapFromChannelStart, RemapChannelLength), RemapToChannelStart); } } From 6ffa884ef42f5fb8dc2bd424ae1cd5d07c2a80f6 Mon Sep 17 00:00:00 2001 From: u-Kotovsky Date: Sun, 11 Jan 2026 22:16:36 +0300 Subject: [PATCH 3/4] Return EnsureCapacity and add one for toggle --- Assets/Plugin/Generators/GeneratorRemapOnDemand.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs index 4dd4c55..d1c2045 100644 --- a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs +++ b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs @@ -14,6 +14,11 @@ public void Construct() { } public void Deconstruct() { } public void GenerateDMX(ref List dmxData) { + //ensure capacity + dmxData.EnsureCapacity(RemapToChannelStart + (int)RemapChannelLength); + dmxData.EnsureCapacity(RemapFromChannelStart + (int)RemapChannelLength); + dmxData.EnsureCapacity(ToggleChannel); + if (dmxData[ToggleChannel] > ActivationThreshold) { dmxData.WriteToListAtPosition(dmxData.GetRange(RemapFromChannelStart, RemapChannelLength), RemapToChannelStart); From 954e2c7d6340a9e953693351761abea5121d70be Mon Sep 17 00:00:00 2001 From: u-Kotovsky Date: Mon, 12 Jan 2026 20:30:36 +0300 Subject: [PATCH 4/4] Use fluent builder standard for the interface --- .../Generators/GeneratorRemapOnDemand.cs | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs index d1c2045..27d6d80 100644 --- a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs +++ b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs @@ -33,40 +33,25 @@ public void GenerateDMX(ref List dmxData) public void ConstructUserInterface(RectTransform rect) { - toggleChannelInputfield = Util.AddInputField(rect, "Toggle Channel"); - toggleChannelInputfield.text = ToggleChannel.ToString(); - toggleChannelInputfield.onEndEdit.AddListener((value) => - { - ToggleChannel = value; - }); + toggleChannelInputfield = Util.AddInputField(rect, "Toggle Channel") + .WithText(ToggleChannel.ToString()) + .WithCallback(value => { ToggleChannel = value; }); - remapFromChannelStartInputfield = Util.AddInputField(rect, "Remap From Channel Start"); - remapFromChannelStartInputfield.text = RemapFromChannelStart.ToString(); - remapFromChannelStartInputfield.onEndEdit.AddListener((value) => - { - RemapFromChannelStart = value; - }); + remapFromChannelStartInputfield = Util.AddInputField(rect, "Remap From Channel Start") + .WithText(RemapFromChannelStart.ToString()) + .WithCallback(value => { RemapFromChannelStart = value; }); - remapToChannelStartInputfield = Util.AddInputField(rect, "Remap To Channel Start"); - remapToChannelStartInputfield.text = RemapToChannelStart.ToString(); - remapToChannelStartInputfield.onEndEdit.AddListener((value) => - { - RemapToChannelStart = value; - }); + remapToChannelStartInputfield = Util.AddInputField(rect, "Remap To Channel Start") + .WithText(RemapToChannelStart.ToString()) + .WithCallback(value => { RemapToChannelStart = value; }); - remapChannelLengthInputfield = Util.AddInputField(rect, "Remap Channel Length"); - remapChannelLengthInputfield.text = RemapChannelLength.ToString(); - remapChannelLengthInputfield.onEndEdit.AddListener((value) => - { - RemapChannelLength = value; - }); + remapChannelLengthInputfield = Util.AddInputField(rect, "Remap Channel Length") + .WithText(RemapChannelLength.ToString()) + .WithCallback(value => { RemapChannelLength = value; }); - activationThresholdInputfield = Util.AddInputField(rect, "Activation Threshold"); - activationThresholdInputfield.text = ActivationThreshold.ToString(); - activationThresholdInputfield.onEndEdit.AddListener((value) => - { - ActivationThreshold = value; - }); + activationThresholdInputfield = Util.AddInputField(rect, "Activation Threshold") + .WithText(ActivationThreshold.ToString()) + .WithCallback(value => { ActivationThreshold = value; }); } public void DeconstructUserInterface() { }