Texture
Sandbox.Engine
Derives from Resource
Implements IDisposable

Properties

static Texture Invalid { get; }

1x1 solid magenta colored texture.

static Texture Transparent { get; }

1x1 fully transparent texture.

static Texture White { get; }

1x1 solid white opaque texture.

int Height { get; }

Height of the texture in pixels.

Image format of this texture.

bool IsLoaded { get; }

Whether this texture has finished loading or not.

int Mips { get; }

Number of mip maps this texture has.

Vector2 Size { get; }

Returns a Vector2 representing the size of the texture (width, height)

int Width { get; }

Width of the texture in pixels.

Methods

static Texture2DBuilder Create( int width, int height, ImageFormat format = 0, )
static TextureArrayBuilder CreateArray( int width = 1, int height = 1, int count = 1, ImageFormat format = 0, )
static TextureCubeBuilder CreateCube( int width = 1, int height = 1, ImageFormat format = 0, )

Begin creation of a custom texture. Finish by calling TextureBuilder.Create.

Begins creation of a render target. Finish by calling TextureBuilder.Create. Render targets can be used for fancy things like Graphics.RenderToTexture.

static Texture CreateRenderTarget( string name, ImageFormat format, Vector2 size, )

A convenience function to quickly create a render target. Render targets can be used for fancy things like Graphics.RenderToTexture.

static Texture CreateRenderTarget( string name, ImageFormat format, Vector2 size, Texture oldTexture = null, )

This will create a render target texture if `` is null or doesn't match what you've passed in. This is designed to be called regularly to resize your texture in response to other things changing (like the screen size, panel size etc).

static Texture3DBuilder CreateVolume( int width, int height, int depth, ImageFormat format = 0, )
static Texture Find( string filename, )
static Texture Load( BaseFileSystem filesystem, string filename, bool warnOnMissing = true, )
static Texture Load( string filename, bool warnOnMissing = true, )

This version is able to load http images - but not images from disk

static Task<Texture> LoadAsync( BaseFileSystem filesystem, string filename, bool warnOnMissing = true, )

Load a texture asynchronously. Will return when the texture is loaded and valid. This is useful when loading textures from the web.

static Texture LoadAvatar( long steamid, )

Load avatar image of a Steam user.

static Texture LoadAvatar( string steamid, )

Load avatar image of a Steam user.

virtual void Dispose( )
Implements IDisposable.Dispose

Will release the handle for this texture. If the texture isn't referenced by anything else it'll be released properly. This will happen anyway because it's called in the destructor. By calling it manually you're just telling the engine you're done with this texture right now instead of waiting for the garbage collector.

Color32[] GetPixels( int mip = 0, )

Reads pixel colors from the texture at the specified mip level

void Update( ReadOnlySpan<byte> data, int x = 0, int y = 0, int width = 0, int height = 0, )
void Update3D( ReadOnlySpan<byte> data, int x = 0, int y = 0, int z = 0, int width = 0, int height = 0, int depth = 0, )