It there a Start() equivalence for a static class?

Hello,

I have a static class and wanted to use the Start() method within it. But it did not work. So I googled and found out that I cannot use it outside of MonoBehavior. Unfortunately I did not find out, what I can use instead. I need to create references to another scripts, when the game starts.

My code:

public static class Helper
{
    public static StateData data;
    public static StateManager stateManager;

    public static void Start()
    {
        Transform player = GameObject.FindWithTag("Player").transform; 
        stateManager = player.GetComponent<ProcanimStateManager>(); 
        data = stateManager.data;
    }
    ...
}

In what other way can I create the references just once I start the game?

Thank you
Huxi

You could use Unity - Scripting API: RuntimeInitializeOnLoadMethodAttribute which tells Unity to call a static method when the game starts - but is that what you really want? Your scene with the player might not even be loaded yet. It won’t get called if you reload the scene again (you’d have to quit the game and start it again).
Usually you would have some “Helper” MonoBehaviour instance in your scene and use that, and use normal Start method. In that case, I’d recommend you to use a serialized reference to the player instead of calling Find, unless there’s a special reason for that.