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

robot_2Generated
code_blocksInput

Description

The Load method is a static method of the Texture class in the Sandbox namespace. It is used to load a texture from a specified file path within a given file system. This method returns a Texture object representing the loaded texture.

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 specifying the path to the texture file within the file system.
  • warnOnMissing: A bool indicating whether to log a warning if the texture file is missing.

The method will return a Texture object if the file is successfully loaded. If the file is not 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 filePath = "textures/mytexture.vtex";
bool warnIfMissing = true;

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

if (myTexture != null && !myTexture.IsError)
{
    // Use the texture
    // ...
}
else
{
    // Handle the error
    // ...
}