bool TryGetParameterIndex( string name, System.Int32& index )

book_4_sparkGenerated
code_blocksInput

Description

The TryGetParameterIndex method attempts to retrieve the index of a parameter within the animation graph by its name. This method is useful when you need to work with parameters dynamically and need to know their index for further operations.

Usage

To use the TryGetParameterIndex method, provide the name of the parameter you are looking for as a string. The method will output the index of the parameter if it exists. The method returns a boolean indicating whether the parameter was found.

If the parameter is found, the method returns true and sets the index output parameter to the parameter's index. If the parameter is not found, the method returns false and the index is not modified.

Example

// Example usage of TryGetParameterIndex
AnimationGraph animGraph = new AnimationGraph();
int parameterIndex;

if (animGraph.TryGetParameterIndex("WalkSpeed", out parameterIndex))
{
    // Parameter found, use parameterIndex for further operations
    Console.WriteLine($"Parameter 'WalkSpeed' found at index: {parameterIndex}");
}
else
{
    // Parameter not found
    Console.WriteLine("Parameter 'WalkSpeed' not found.");
}