Hi guys I’ve bought a weather asset and it uses callbacks to initiate the particle systems…
I’ve never used callbacks before and I’m really struggling.
Can anyone tell me in simple form how to invoke a callback function from script? I’ve tried Google and the forums and it seems to be a dark void.
“Callback” is a little vague and could mean lots of things. If you’ve got a function like this:
public void MyCallback()
and you’re calling a function where you have to pass in a function to call back to, you just use the name of the function:
DoAThingWithACallback(MyCallback);
If it’s an event named “OnSomeEvent” and you need to subscribe to it, you do this:
whatever.OnSomeEvent += MyCallback;
makeshiftwings:
“Callback” is a little vague and could mean lots of things. If you’ve got a function like this:
public void MyCallback()
and you’re calling a function where you have to pass in a function to call back to, you just use the name of the function:
DoAThingWithACallback(MyCallback);
If it’s an event named “OnSomeEvent” and you need to subscribe to it, you do this:
whatever.OnSomeEvent += MyCallback;
public void RainToggleChanged(bool isOn)
{
WeatherScript.CurrentPrecipitation = (isOn ? WeatherScript.RainScript : null);
}
Here is an example of the callback I need to activate, I’ve tried
RainToggleChanged (); but nothing happens
It has a bool argument in the function, try:
RainToggleChanged(true);
I’m wondering if you’re actually trying to use Delegates.
Could you just post all of your code together? I’m sure someone can help very quickly on this forum.
Hi guys sorry for late reply its been a long weekend here. Ill up load the script code after work. The asset author specifically said they were callback functions. But wouldn’t tell me how to use them lol. Tough love I guess.