Hi!
I was wondering if there is any way to set a parameter through the send message function in the Studio Event Emitter?
Hi!
I was wondering if there is any way to set a parameter through the send message function in the Studio Event Emitter?
SendMessage
is a feature of Unity GameObjects that allows you to call any method on a GameObject, but it is restricted to sending a single value so you would need to make a wrapper function to call StudioEventEmitter.SetParameter
:
// CallerScript.cs
gameObject.SendMessage("SetParameterWrapper", new { name = "Size", value = Random.Range(0.0f, 3.0f), ignoreseekspeed = false});
...
// StudioEventEmitter.cs
public void SetParameterWrapper(object o)
{
string name = (string)o.GetType().GetProperty("name").GetValue(o, null);
float value = (float)o.GetType().GetProperty("value").GetValue(o, null);
bool ignoreseekspeed = (bool)o.GetType().GetProperty("ignoreseekspeed").GetValue(o, null);
SetParameter(name, value, ignoreseekspeed);
}
Relying on SendMessage would violate good software design principles and is relatively expensive/convoluted compared to just calling SetParameter on the StudioEventEmitter itself, so use it sparingly!