Texture Create( string name, bool anonymous, System.ReadOnlySpan<System.Byte> data, int dataLength )

book_4_sparkGenerated
code_blocksInput

Description

The Create method of the TextureBuilder class is used to create a new Texture instance. This method allows you to specify the name, anonymity, and data of the texture, as well as the length of the data. It is a non-static, public method that returns a Texture object.

Usage

To use the Create method, you need to have an instance of TextureBuilder. You can then call the method with the appropriate parameters:

  • name: A string representing the name of the texture.
  • anonymous: A bool indicating whether the texture should be anonymous.
  • data: A ReadOnlySpan<byte> containing the texture data.
  • dataLength: An int specifying the length of the data.

Example

// Example of creating a texture using TextureBuilder
TextureBuilder builder = new TextureBuilder();

// Define texture data
string textureName = "MyTexture";
bool isAnonymous = false;
byte[] textureData = new byte[] { /* texture data bytes */ };
int dataLength = textureData.Length;

// Create a ReadOnlySpan from the byte array
ReadOnlySpan<byte> dataSpan = new ReadOnlySpan<byte>(textureData);

// Create the texture
Texture texture = builder.Create(textureName, isAnonymous, dataSpan, dataLength);

// Use the texture in your application