Component:AssetMultiplexer: Difference between revisions

From Resonite Wiki
add information about referencemultidriver
m Add extra information to Examples to prevent headaches for future people
 
Line 20: Line 20:
== Usage ==
== Usage ==
Add the list of assets you want to use through the SyncAssetList<IAsset`1> area, then add in your assets into the items. Then you can specify the field through the Target you wanna switch between different assets for. Changing the Index will change which asset the Target has in it.
Add the list of assets you want to use through the SyncAssetList<IAsset`1> area, then add in your assets into the items. Then you can specify the field through the Target you wanna switch between different assets for. Changing the Index will change which asset the Target has in it.
Ensure you can set the Target field on this component before making any other components reference the Index field on this component if you don't wanna waste your time.


{{Note|This component directly drives a value, not a reference. Therefore, trying to combine it with other components using an [[Type:IAssetProvider|IAssetProvider]]<T> type, such as a [[Component:ReferenceMultiDriver|ReferenceMultiDriver]], will not work. To drive by reference and thus interop this component, use a [[Component:ReferenceMultiDriver|ReferenceMultiDriver]]<IAssetProvider<T>>|information}}
{{Note|This component directly drives a value, not a reference. Therefore, trying to combine it with other components using an [[Type:IAssetProvider|IAssetProvider]]<T> type, such as a [[Component:ReferenceMultiDriver|ReferenceMultiDriver]], will not work. To drive by reference and thus interop this component, use a [[Component:ReferenceMultiDriver|ReferenceMultiDriver]]<IAssetProvider<T>>|information}}
Line 26: Line 28:
== Examples ==
== Examples ==
Using an asset multiplexer to allow your avatar to switch shirts via changing the texture, a pattern changer for a music visualizer.
Using an asset multiplexer to allow your avatar to switch shirts via changing the texture, a pattern changer for a music visualizer.
To do texture swapping, use AssetMultiplexer<[[Type:ITexture2D]]>, not to be confused with AssetMultiplexer<[[Type:Texture2D]]>


<!--T:6-->
<!--T:6-->

Latest revision as of 20:16, 9 August 2025

Component image 
Asset Multiplexer`1 component as seen in the Scene Inspector

The AssetMultiplexer component is used to drive an asset field from a list of assets and an index within the list.

Fields

Fields
Name Type Description
persistent Bool Determines whether or not this item will be saved to the server.
UpdateOrder Int Controls the order in which this component is updated.
Enabled Bool Controls whether or not this component is enabled. Some components stop their functionality when this field is disabled, but some don't.
Target reference drive of AssetRef`1<A> The field to drive.
Index Int Which element in Assets to drive to Target
Assets list of A The list of assets to multiplex between.

Usage

Add the list of assets you want to use through the SyncAssetList<IAsset`1> area, then add in your assets into the items. Then you can specify the field through the Target you wanna switch between different assets for. Changing the Index will change which asset the Target has in it.

Ensure you can set the Target field on this component before making any other components reference the Index field on this component if you don't wanna waste your time.

This component directly drives a value, not a reference. Therefore, trying to combine it with other components using an IAssetProvider<T> type, such as a ReferenceMultiDriver, will not work. To drive by reference and thus interop this component, use a ReferenceMultiDriver<IAssetProvider<T>>

Examples

Using an asset multiplexer to allow your avatar to switch shirts via changing the texture, a pattern changer for a music visualizer.

To do texture swapping, use AssetMultiplexer<Type:ITexture2D>, not to be confused with AssetMultiplexer<Type:Texture2D>

Related Components