class Texture

in global :: Sandbox

A texture is an image used in rendering. Can be a static texture loaded from disk, or a dynamic texture rendered to by code. Can also be 2D, 3D (multiple slices), or a cube texture (6 slices).


public static Texture2DBuilder Create( int width, int height, ImageFormat format = RGBA8888 )

Begins creation of a custom texture. Finish by calling .

public static Texture3DBuilder CreateVolume( int width, int height, int depth, ImageFormat format = RGBA8888 )

Begins creation of a custom 3D texture. Finish by calling .

public static TextureCubeBuilder CreateCube( int width = 1, int height = 1, ImageFormat format = RGBA8888 )

Begins creation of a custom cube texture. (A texture with 6 sides) Finish by calling .

public static TextureArrayBuilder CreateArray( int width = 1, int height = 1, int count = 1, ImageFormat format = RGBA8888 )

Begins creation of a custom texture array. Finish by calling .

public 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 .

  • name A meaningless debug name for your texture.
  • format The image format.
  • size The size of the texture.
  • Returns The newly created render target texture.

public 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).

  • name A meaningless debug name for your texture.
  • format The image format.
  • size The size of the texture.
  • oldTexture A previously created texture.
  • Returns Will return a new texture, or the .

public bool IsError { get; }

Whether this texture is an error or invalid or not.

public int Index { get; }

Texture index. Bit raw dog and needs a higher level abstraction.

public int Width { get; }

Width of the texture in pixels.

public int Height { get; }

Height of the texture in pixels.

public int Depth { get; }

Depth of a 3D texture in pixels, or slice count for 2D texture arrays, or 6 for slices of cubemap.

public int Mips { get; }

Number of mip maps this texture has.

public Vector2 Size { get; }

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

public bool IsLoaded { get; }

Whether this texture has finished loading or not.

public ImageFormat ImageFormat { get; }

Image format of this texture.

public int LastUsed { get; }

Returns how many frames ago this texture was last used by the renderer

public Vector4 SequenceData { get; }

If this texture is a sprite sheet, will return information about the sheet, which is generally used in the shader. You don't really need to think about the contents.

public int SequenceCount { get; }

The count of sequences in this texture, if any. The rest of the sequence data is encoded into the texture itself.

public int GetSequenceFrameCount( int sequenceId )

Get the frame count for this sequence

public void MarkUsed( int requiredMipSize = 0 )

Tells texture streaming this texture is being used. This is usually automatic, but useful for bindless pipelines.

public Nullable<EmbeddedResource> GenerationData { get; set; }

Data used by the generator to create the texture

public static Texture Load( BaseFileSystem filesystem, string filepath, bool warnOnMissing = True )

Try to load a texture from given filesystem, by filename.

public static Texture Load( string url, bool warnOnMissing = True )

Try to load a texture. This version is able to load http images - but not images from disk.

public static Texture LoadAvatar( long steamid )

Load avatar image of a Steam user.

  • steamid The SteamID of the user to load avatar of.
  • Returns The avatar texture.

public static Texture LoadAvatar( string steamid )

🤡 Doc inheritance is not yet supported.

No summary.

public static Task<Texture> LoadAsync( BaseFileSystem filesystem, string filepath, 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.

public static Texture Find( string filepath )

Try to get an already loaded texture.

  • filepath The filename of the texture.
  • Returns The already loaded texture, or null if it was not yet loaded.

public Color32[] GetPixels( int mip = 0 )

Reads pixel colors from the texture at the specified mip level

public Color32 GetPixel( float x, float y, int mip = 0 )

Reads a single pixel color.

public Color32 GetPixel3D( float x, float y, float z, int mip = 0 )

Reads a single pixel color from a volume or array texture.

public static Texture Invalid { get; }

1x1 solid magenta colored texture.

public static Texture White { get; }

1x1 solid white opaque texture.

public static Texture Transparent { get; }

1x1 fully transparent texture.

public void Update( Color32 color, Rect rect )

Write a coloured rectangle to the texture

public void Update( Color32 color, float x, float y )

Write a coloured pixel to the texture

public void Update( ReadOnlySpan<Color32> data, int x = 0, int y = 0, int width = 0, int height = 0 )

😔 No documentation found.

public string ResourcePath { get; }

😔 No documentation found.

public bool HasUnsavedChanges { get; }

😔 No documentation found.

public string ResourceName { get; }

😔 No documentation found.

public Type GetType( )

😔 No documentation found.

public void StateHasChanged( )

😔 No documentation found.

public string ToString( )

😔 No documentation found.

public bool IsValid { get; }

😔 No documentation found.

public int ResourceId { get; }

😔 No documentation found.

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

😔 No documentation found.

public int GetHashCode( )

😔 No documentation found.

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

😔 No documentation found.

public void GetPixels3D( ValueTuple<int,int,int,int,int,int> srcBox, int mip, Span<T> dstData, ImageFormat dstFormat, ValueTuple<int,int,int> dstSize = null )

😔 No documentation found.

public void GetPixels( ValueTuple<int,int,int,int> srcRect, int slice, int mip, Span<T> dstData, ImageFormat dstFormat, ValueTuple<int,int,int,int> dstRect, int dstStride )

😔 No documentation found.

public void GetPixels( ValueTuple<int,int,int,int> srcRect, int slice, int mip, Span<T> dstData, ImageFormat dstFormat, ValueTuple<int,int> dstSize = null )

😔 No documentation found.

public Bitmap GetBitmap( int mip )

😔 No documentation found.

public bool Equals( object obj )

😔 No documentation found.

public ResourceGenerator<Texture> CreateGenerator( )

😔 No documentation found.

public bool HasAnimatedSequences { get; }

😔 No documentation found.

public void Dispose( )

😔 No documentation found.

public static Texture CreateFromSvgSource( string svgContents, Nullable<int> width, Nullable<int> height, Nullable<Color> color )

😔 No documentation found.

public static TextureBuilder CreateRenderTarget( )

😔 No documentation found.

public void Update( ReadOnlySpan<T> data, int x = 0, int y = 0, int width = 0, int height = 0 )

😔 No documentation found.

public static TextureBuilder CreateCustom( )

😔 No documentation found.