Invoke – delay time in Unity

Invoke method allows us to call a function with delay specified as an argument.

Invoke method can be used with the methods of void type that has no parameters.

    // We can use Invoke method to call a function with delay
    // Function that is being called should be of type void and has no parameters
    // If different type of function is needed we can use Coroutines

    void Start()
    {
        Invoke("DisplayDelayedMessage", 2);
    }

    public void DisplayDelayedMessage()
    {
        print("Hej");
    }