diff --git a/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs new file mode 100644 index 0000000..27d6d80 --- /dev/null +++ b/Assets/Plugin/Generators/GeneratorRemapOnDemand.cs @@ -0,0 +1,60 @@ +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); + dmxData.EnsureCapacity(ToggleChannel); + + if (dmxData[ToggleChannel] > ActivationThreshold) + { + dmxData.WriteToListAtPosition(dmxData.GetRange(RemapFromChannelStart, RemapChannelLength), RemapToChannelStart); + } + } + + 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") + .WithText(ToggleChannel.ToString()) + .WithCallback(value => { ToggleChannel = value; }); + + remapFromChannelStartInputfield = Util.AddInputField(rect, "Remap From Channel Start") + .WithText(RemapFromChannelStart.ToString()) + .WithCallback(value => { RemapFromChannelStart = value; }); + + remapToChannelStartInputfield = Util.AddInputField(rect, "Remap To Channel Start") + .WithText(RemapToChannelStart.ToString()) + .WithCallback(value => { RemapToChannelStart = value; }); + + remapChannelLengthInputfield = Util.AddInputField(rect, "Remap Channel Length") + .WithText(RemapChannelLength.ToString()) + .WithCallback(value => { RemapChannelLength = value; }); + + activationThresholdInputfield = Util.AddInputField(rect, "Activation Threshold") + .WithText(ActivationThreshold.ToString()) + .WithCallback(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