Not sure if this helps anyone but it served a purpose for us. Thought I’d quickly post it for everyone:
http://unifycommunity.com/wiki/index.php?title=DelayedDelegates
It’s a static class that allows you to call a function with a delay and a parameter (or a customer set of parameters) (float,int,Vector2,Vector3,string,GameObject)
void MyFunction(int param)
{
// Do something with param
}
// Replace '1' with your int, float, etc....
DelayedDelegates.Add(MyFunction, 1, 2)
You can inherit from DelegateParameters if you need custom params sent through:
public class MyParams : DelegateParameters
{
public int myParam1;
public string myParam2;
public MyParams(int myParam1, string myParam2)
{
this.myParam1 = myParam1;
this.myParam2 = myParam2;
}
}
void MyFunction(DelegateParameters param)
{
MyParams myParam = (MyParams) param;
Debug.Log(myParam.myParam1 + " : " + myParam.myParam2);
}
DelayedDelegates.Add(MyFunction, new MyParams(1,"HELLOW WORLD"), 2);
It might seem like more code to do the same thing that Invoke does but it’s a bit nicer and easier to manage between MonoBehaviour scripts