static Task<Material> LoadAsync( string filename )

book_4_sparkGenerated
code_blocksInput

Description

The LoadAsync method is a static method of the Material class in the Sandbox namespace. It is used to asynchronously load a material from a specified file. This method returns a Task<Material>, which represents the asynchronous operation and eventually provides the loaded Material object.

Usage

To use the LoadAsync method, call it with the filename of the material you wish to load. This method is asynchronous, so you should await its completion to get the resulting Material object.

Parameters:

  • filename (String): The path to the material file you want to load.

Returns: A Task<Material> that represents the asynchronous operation. The task result contains the loaded Material object.

Example

// Example of using LoadAsync to load a material
async Task LoadMaterialExample()
{
    string materialPath = "materials/my_material.mat";
    Material material = await Material.LoadAsync(materialPath);
    
    if (material != null)
    {
        // Use the loaded material
        Console.WriteLine($"Material '{material.Name}' loaded successfully.");
    }
    else
    {
        Console.WriteLine("Failed to load material.");
    }
}