binarytotexture
- Last UpdatedFeb 19, 2025
- 3 minute read
The binarytotexture statement can be used inside Command or Coroutine to update the content of a Texture2D node by using the binary data stored inside an sbinary field. To use this command, the target Texture2D must have its mode set to mirror.
The typical use case for this command is to populate a Texture2D set to mirror mode using the content of an sbinary field previously filled with image data by the texturetobinary command.
Command sequence
By implementing the following commands sequence, it is possible to mirror the graphic displayed in the original Texture2D node inside the mirrored Texture2D node.
OriginalTexture2D > texturetobinary > SBinary > binarytotexture > MirroredTexture2D
binarytotexture and texturetobinary
The opposite of this command, namely to store the content of a Texture2D node instance inside an sbinary field, can be achieved by using the texturetobinary command.
Platform support
This command is supported on all platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
Code example
The following code example loads the image data content of the sbinary field (named mySBinary) and loads it inside the Texture2D node (named myTexture2D). The graphics displayed by the Texture2D are updated to display the provided image data. The Texture2D must have its mode set to mirror to allow update using the binarytotexture command.
Notice that by routing the mySBinary.value field to the cmd_runBinaryToTexture command the content of the myTexture2D node is automatically updated from the mySBinary field every time the mySBinary is updated with new content, such as when it is updated using shares.
<Command name="cmd_runBinaryToTexture">
<binarytotexture name="mySBinary.value" texture=" myTexture2D " />
</Command>
<route from="mySBinary.value" to="cmd_runBinaryToTexture.execute" />
Fields
These are the fields for binarytotexture statement.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
|
sstring |
Mandatory |
No default value |
The name of the SBinary value field that will be used to store the Texture2D image data. |
|
texture |
sstring |
Mandatory |
No default value |
The name of the Texture2D node from which the image data will be taken. |