bool Set( string param, Vector4 value )
bool Set( string param, Texture texture )
bool Set( string param, Color value )
bool Set( string param, Vector3 value )
bool Set( string param, Vector2 value )
bool Set( string param, float value )
bool Set( string param, int value )
bool Set( string param, bool value )

book_4_sparkGenerated
code_blocksInput

Description

The Set method in the Material class is used to assign a Vector4 value to a specified parameter within the material. This method is useful for dynamically changing material properties at runtime, such as colors, positions, or other vector-based attributes.

Usage

To use the Set method, you need to provide the name of the parameter you wish to modify and the Vector4 value you want to assign to it. The method returns a Boolean indicating whether the operation was successful.

Parameters:

  • param (System.String): The name of the parameter to set.
  • value (Vector4): The Vector4 value to assign to the parameter.

Returns: System.Boolean - true if the parameter was successfully set; otherwise, false.

Example

// Example of using the Set method to change a material's parameter
Material myMaterial = Material.Load("materials/my_material.vmat");

// Define a Vector4 value
Vector4 newValue = new Vector4(1.0f, 0.5f, 0.25f, 1.0f);

// Set the parameter named "MyParameter" to the new Vector4 value
bool success = myMaterial.Set("MyParameter", newValue);

if (success)
{
    // The parameter was successfully set
    // Additional logic can be added here
}
else
{
    // Handle the failure case
}