We are developing a online game. I wrote a network module using socket and C# for client. I need a global function call to fetch network events(OnConnect, OnDisconnect, OnMsg). The call should be called continuely even when change map/level or windows minimizd.

Who can tell me how to make this? It seems only a game object can have a script attached on it.

Thanks a lot.

You can write classes that don't inherit from MonoBehaviour. You can instantiate those as you would in normal applications. If you just don't want the Object to be destroyed on LoadLevel use GameObject.DontDestroyOnLoad(). If you want functions to be called when the window is minimized you'll need to activate RunInBackground in the PlayerSettings.