The '''ValueMultiplexer''' component allow to curate a list of values and [[Drive|drive]] a target with one of them, much like a multiplexer.
The '''ValueMultiplexer''' component allow to curate a list of values and [[Drive|drive]] a target with one of them, much like a multiplexer.
== Usage ==
== Fields ==
{{Table ComponentFields
{{Table ComponentFields
|Target|{{RootFieldType|FieldDrive`1|T}}|TypeAdv0=true|A field which is driven with the currently selected list value
|Target|{{RootFieldType|FieldDrive`1|T}}|TypeAdv0=true|A field which is driven with the currently selected list value
Line 14:
Line 14:
}}
}}
== Behavior ==
== Usage ==
The component behaves similar to a [[Component:ValueCopy|ValueCopy]] with the list entry indicated by <code>Index</code> as the value to output. Changes to <code>Index</code> or the list entries will affect <code>Target</code> whenever the drive is evaluated.
The component behaves similar to a [[Component:ValueCopy|ValueCopy]] with the list entry indicated by <code>Index</code> as the value to output. Changes to <code>Index</code> or the list entries will affect <code>Target</code> whenever the drive is evaluated.
Revision as of 10:39, 7 December 2024
Component image
Value Multiplexer`1 component as seen in the Scene Inspector
The ValueMultiplexer component allow to curate a list of values and drive a target with one of them, much like a multiplexer.
Setting this to true redirects writes from Target or from a Source representing the selected value to the currently indexed list entry.
Usage
The component behaves similar to a ValueCopy with the list entry indicated by Index as the value to output. Changes to Index or the list entries will affect Target whenever the drive is evaluated.
In addition, the component implements the IValue type. This allows the component to be sourced by dragging out the component header with the ProtoFlux tip. This enables using the component like an array when sourcing the Index field as well. The source of this component will update instantly, as opposed to the drive being limited to once per frame.
Examples
Array-like access from within ProtoFlux. Note the setting of AllowWriteBack and that you can only access a single value at a time!
A demonstration of what happens when Index is outside the usual range. (wraps around)