xxxxxxxxxx
void CallMe() {
// Invoke("MethodName", Delay seconds as float);
Invoke("CallMeWithWait", 1f);
}
void CallMeWithWait() {
// Do something
}
xxxxxxxxxx
// This function will be called by the "Invoke" after 3 seconds and change the
// gameobject color"playerColor"
void ChangeColor()
{
playerColor = Color.blue;
GetComponent<MeshRenderer>().material.color = playerColor;
Debug.Log("color is: " + playerColor);
}
// If the gameobject color is not yellow than this code "Invoke" will wait for the 3 seconds
// the float at the end than will call the function at the beginning
// "void ChangeColor()"
void Update()
{
if (playerColor != Color.yellow)
{
Invoke(nameof(ChangeColor), 3f));
}