It’s been a while since I got to sit down and write some code. There’s one project that’s been on my mind for years, but it’s languished for some time. I decided to give it another go, this time using Unity instead of HTML5.
Since this project is probably going to take quite a while, and I’m not really expecting much from it in a return on investment point of view, I’m using the free Unity. Free Unity, as you probably know, lacks .Net sockets for mobile platforms. Since I’d really like to get it working on iOS, and don’t have $3000 to spend on Unity Pro and iOS Pro, I’m going to stick with the old GET/POST method I started with back when I was using HTML5.
To communicate with my server then, I’ve been using the WWW class in Unity.
WWW www = new WWW ("http://server/function.php", pData, headers);
However, because WWW runs as an Enumerator and requires
yield return www
I was having all sorts of trouble getting the result from the WWW GET.
What seems to be working for was to put the WWW command in its own Unity C# script, use evil global variables, and run it by using:
gameObject.AddComponent("Login");
I’m still hoping to find a way to pass parameters to the added component, rather than using global variables, but I feels good to finally start passing some sanity checks!