Hi,
Can we change the pitch of an AudioMixer by code (C#)? We can from the inspector.
It’s seems like the AudioMixer object don’t have any method for this.
Thank you.
Hi,
Can we change the pitch of an AudioMixer by code (C#)? We can from the inspector.
It’s seems like the AudioMixer object don’t have any method for this.
Thank you.
You have to expose the Pitch parameter to script control. Right click on the parameter name “Pitch” and choose “Expose ‘Pitch’ to script”. Give it a name in the Exposed Parameters drop down on the AudioMixer view in the editor. Then you can use mixer.SetFloat(“myParameterName”, 0.5f); to change the value from one of your scripts.
Thank you for your response!
If someone is looking where the dropdown is, here is a picture that shows.
Thank you both for the information relating to finding the exposed parameters - that was quite a search!
Is this not what I should do?
exposer param:
I get this error on the “.5f”:
You just need to declare a float variable to put the retrieved value into:
float myPitchValue;
audioMixer.GetFloat("pitch", out myPitchValue);
print("myPitchValue: " + myPitchValue.ToString());