Hi, I’m trying to access a parameter max value to use it in my code.
I found this topic looking through the forums, wich was really helpful: Read out parameter Min and Max value?.
I follow what I understand is the logical way to achive my goal, but I can not make it work.
I’m sharing my code:
public void SetLevelParameter(int value, int maxValue)
{
int parameterMaxValue;
PARAMETER_DESCRIPTION parameterDescription = default;
musicInstance.getDescription(out EventDescription description);
if (description.isValid())
description.getParameterDescriptionByName(levelPN, out parameterDescription);
else
Debug.LogWarning("There is no description for music event");
parameterMaxValue = (int)parameterDescription.maximum;
float levelsPerTrack = maxValue / parameterMaxValue;
int fixValue = Mathf.FloorToInt(value / levelsPerTrack);
musicInstance.setParameterByName(levelPN, fixValue);
}
I always get: “There is no description for music event” or an error saying that I can not divide by zero (this line: float levelsPerTrack = maxValue / parameterMaxValue;)
Any help on how to properly access parameter’s max value would be great!
Thanks.