- Home /
Testing Network Code in Unity
I am currently working on getting some network code to work. And since I am not that good at programming, I need to test ALOT to make sure my code works, so I don't end up in a situation where something breaks, and I have to use alot of time trying to figure out what I broke.
So right now, I export what I have, to my labtop, set up my desktop as a server, and connect from my labtop. If I try to do everything from my desktop, only the active program running will update (So if my server window is not active, everything freezes) It is absolutely annoying that I have to export and transfer everytime, and have a setup of two coputer to test. Does anyone have experience and some suggestions how I can do quick itterative testing on only one computer?
Thanks for your time :)
Answer by rstuven · Aug 30, 2011 at 09:45 AM
Enable "Run in background" option in Player Settings.
Answer by Techsuport · Aug 28, 2011 at 07:33 PM
what you should be doing is have playInBackground turned on, so the editor and any instances of the game still update the networking stuff.
and for networking i plan to make my projects hostable online so i build for the web player, and i can have multiple instances of my project open in different browser tabs, while staying connected to that network in the editor (still able to interact with the project view)
this way you dont have to use a thrd party app
I dont understand, how can you have several instances running in different tabs? Does that work with playInBackground? And where do you set playInBackground?
Answer by DaveA · Jun 16, 2011 at 08:47 PM
You can set up a local server. I like ServerToGo. It can also be a real server, but I wouldn't trust it for being very secure that way. But for local testing, it's great. PHP and mySQL come with it.
BTW: No matter how good you are at programming, a LOT of testing is always a good idea.
This is kinda what I do, my problem is that I have to have a setup of two computers. What I would like, would be something where I just export to the same computer, run and connect to the server that is run from the editor.
Answer by Tabu · Aug 28, 2011 at 11:38 AM
Ok, so I found a propper sollution for this. It acually working ok, and its free :)
I installed an old XP on Virtual Box: (http://www.virtualbox.org/) From here I can easily just share a folder, and run the game server in the Virtual Machine, then go outside without loosing focus to launch my game. Works fine :) And I dont have to have a setup of more real machines to test my network code.
Pointers if you try to do this. Remember to set it up so that the VM uses the graphic card (as basic, it has no graphic card.) and add a network card and set it to "host only" this will make it easier to test stuff.
Having trouble doing this, let me know and I will help :)