static Texture Load( BaseFileSystem filesystem, string filepath, bool warnOnMissing )
static Texture Load( string url, bool warnOnMissing )

book_4_sparkGenerated
code_blocksInput

Description

The Load method is a static method of the Texture class in the Sandbox API. It is used to load a texture from a specified file path within a given file system. This method is useful for loading textures that are stored on disk and need to be used within the game or application.

Usage

To use the Load method, you need to provide the following parameters:

  • filesystem: An instance of BaseFileSystem that represents the file system from which the texture will be loaded.
  • filepath: A string representing the path to the texture file within the specified file system.
  • warnOnMissing: A bool indicating whether a warning should be issued if the texture file is not found.

The method returns a Texture object representing the loaded texture. If the texture cannot be found and warnOnMissing is set to true, a warning will be logged.

Example

// Example of loading a texture from a file system
BaseFileSystem fileSystem = FileSystem.Mounted;
string texturePath = "textures/mytexture.vtex";
bool warnIfMissing = true;

Texture myTexture = Texture.Load(fileSystem, texturePath, warnIfMissing);

if (myTexture.IsError)
{
    // Handle error
    Console.WriteLine("Failed to load texture.");
}
else
{
    // Use the texture
    Console.WriteLine("Texture loaded successfully.");
}