■ Invoke 개념

○ Invoke

using UnityEngine;

public class InvokeExample : MonoBehaviour
{
    void Start()
    {
        Invoke("PrintMessage", 2f); // 2초 후에 PrintMessage를 호출
    }

    void PrintMessage()
    {
        Debug.Log("Invoke 호출됨!");
    }
}
// 이 코드에서는 유니티가 Start 메서드를 호출한 후 2초가 지나면 PrintMessage 메서드가 실행됩니다.

○ InvokeRepeating - 반복 호출

using UnityEngine;

public class InvokeRepeatingExample : MonoBehaviour
{
    void Start()
    {
        InvokeRepeating("PrintMessage", 1f, 2f); // 1초 후부터 시작, 2초 간격으로 호출
    }

    void PrintMessage()
    {
        Debug.Log("반복 호출 중!");
    }
}
// 이 코드에서는 PrintMessage 메서드가 1초 후에 시작하고, 이후 2초 간격으로 계속 호출됩니다.

○ Invoke 중지


■ .Invoke()

○ .Invoke() 개념