- Home /
Global update function for network
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.
Answer by StephanK · Apr 01, 2011 at 10:50 AM
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.
Thanks Spree. I have found the "Run In Background*" setting and make it work when the game windows lost focus.
Your answer
Follow this Question
Related Questions
How can I write to a socket accepted from a tcp listener? 1 Answer
Right way to receive Images over tcp? 2 Answers
TCP Problem 0 Answers
System.NotSupportedException: This protocol version is not supported 0 Answers
Android & PC socket connection 1 Answer