Table of Contents

ParameterUtility

ParameterUtility is a static utility class for parameter validation and parsing, to be used with all types of animations and commands.
The full API docs can be found here.

For each of the supported parameter types listed in the previous section, there is a HasXYZParameter method, a HasNonXYZParameter method, a GetXYZParameter and a TryGetXZYParameter method. Each of these methods are explained individually below.

HasParameter

bool HasXYZParameter(IDictionary<string, string>, string name, params string[] aliases) checks whether the given set of parameters contains a parameter of the given name, or any of the aliases, that is of type XYZ.

Example: HasFloatParameter(parameters, "duration", "dur", "d") returns true if parameters contains a parameter named either "duration", "dur" or "d", and the value could be converted to type float. Otherwise, it returns false.

HasNonParameter

bool HasNonXYZParameter(IDictionary<string, string>, string name, params string[] aliases) checks whether the given set of parameters contains a parameter of the given name, or any of the aliases, that is NOT of type XYZ.

Example: HasNonFloatParameter(parameters, "duration", "dur", "d") returns true exactly when parameters contains a parameter named either "duration", "dur" or "d", but the value could NOT be converted to type float. Otherwise, it returns false.

GetParameter

XYZ GetXYZParameter(IDictionary<string, string>, string name, params string[] aliases) returns the parameter defined by the given name, or any of the aliases, converted to type XYZ. Otherwise, it will throw an exception.

Example: GetFloatParameter(parameters, "duration", "dur", "d") throws an exception if parameters does not contain a parameter named either "duration", "dur" or "d", or, if the parameter is defined, it could not be converted to type float. Otherwise, it will return the parameter converted to type float.

TryGetParameter

bool TryGetXYZParameter(out XYZ value, IDictionary<string, string>, string name, params string[] aliases) wraps GetParameter in a try-catch statement, returning true if it was successful, otherwise it returns false. If successful, you can get the value of the converted parameter from the out XYZ value parameter.

Example: TryGetFloatParameter(out float value, parameters, "duration", "dur", "d") returns false if parameters does not contain a parameter named either "duration", "dur" or "d", or, if the parameter is defined, it could not be converted to type float. Otherwise, it will return true and value will be set to the parameter converted to type float.

Array

For array parameters, each of these four methods have an additional required parameter: ParseDelegate<string, T, IDictionary<string, T>,
where ParseDelegate is defined as: public delegate W ParseDelegate<T, U, V, W>(T input, out U output, V keywords).

Essentially, this delegate is used to parse the individual elements of the array.
You can use the ParsingUtility.StringToXYZ methods for this (they are not further explained here, but you can look at the API docs for them).

Example: TryGetArrayParameter<float>(out float[] value, parameters, ParsingUtility.StringToFloat, "numbers", "nums")

ParameterDefined

In addition to these type-specific methods, there are also generic methods for checking whether a parameter is defined, without performing any type checks.
These are:
bool ParameterDefined(IDictionary<string, string>, string name, params string[] aliases): Checks whether a parameter of the given name or any of its aliases is present in the dictionary. EXACTLY one must be defined for this to return true; if for example two aliases are present it is considered not defined.

string GetDefinedParameter(IDictionary<string, string>, string name, params string[] aliases): If the parameter is defined according to ParameterDefined, this will return the value of that parameter. Otherwise, it will throw an exception.

bool TryGetDefinedParameter(out string value, IDictionary<string, string>, string name, params string[] aliases): Wraps GetDefinedParameter in a try-catch statement. If successful, the parameter value will be stored in the out string value parameter.

Waves

If your animation uses Waves, you can use the pre-defined wave parameters set by using ValidateWaveParameters(IDictionary<string, string> parameters, string prefix = "") and GetWaveParameters(IDictionary<string, string> parameters, string prefix = "") in ValidateParameters and SetParameters respectively. The passed in prefix lets you use multiple waves with differently prefixed parameter names.

If you have a default wave, you can combine it with the set parameters like this:

[SerializeField] Wave wave;

public void SetParameters(object customData, IDictionary&lt;string, string&gt; parameters)
{
    Data d = customData as Data; // Cast custom data to whatever type it is
    d.Wave = CreateWave(wave, GetWaveParameters(parameters));
}

This will create a new wave from the set parameters and the values defined in the default wave as fallback values for the non-set parameters.

For the full list of parameters that are part of the wave parameters set, see the API documentation.