Define entry point function in Unity (use in static class)

How can I define entry point static function like:

public static class UnityClass
{
    [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.AfterSceneLoad)]
    private static void UnityInitMethod()
    {
        Init();
    }
    
    [UnityEngine.RuntimeCleanUpMethod(UnityEngine.RuntimeCleanUpType.BeforeOnApplicationQuit)]
    private static void UnityCleanUpMethod()
    {
         Clean();
     }
}

The first method already answers your question, and the lower one uses an attribute that doesn’t exist?

I’ll just assume that what you really want is a method that is called when the game is closed?
In that case, spawn a GameObject, put a MonoBehaviour on it that has the OnApplicationQuit method and react to that.

public static class UnityClass
{
    private class Worker : MonoBehaviour
    {
        private void OnApplicationQuit()
        {
            Clean();
        }
    }

    [RuntimeInitializeOnLoadMethod( ... )]
    private static void UnityInitMethod() 
    {
        Init();

        var gameObject = new GameObject("OnApplicationQuit Worker");
        gameObject.AddComponent<Worker>();
        Object.DontDestroyOnLoad(gameObject);
        gameObject.hideFlags = HideFlags.HideAndDontSave;
    }
}

Thanks so much. It worked.