Skip to main content
Version: 20 Mar 2024

MLTextureUtils

NameSpace: Native

Class containing utility functions to convert Unity Texture to Magic Leap OS compatible data structures.

Public Methods

byte [] ConvertToByteArray

Convert Unity Texture2D to a byte array. Texture2D should be in one of the following formats: DXT1, RGBA32, RGB24. For DXT1 and RGBA32, resulting byte array is in RGBA format. For RGB24, resulting byte array is in RGB format. The origin of the byte array will be at the top left corner. Returns null on unsupported formats.

public static byte [] ConvertToByteArray(
Texture2D texture,
out int numChannels
)

Parameters

TypeNameDescription
Texture2DtextureTexture to extract byte array from
out intnumChannelsOut parameter to determine how many bytes per pixel

Returns: Returns an array of bytes that holds the converted texture