Hacker News new | ask | show | jobs
by darklajid 4822 days ago
The title sounded very interesting, I'm highly interested in Unity and Indoor positioning. But .. that's not part of that article. This is just a tiny C# class for network operations in Unity, it seems?

Disclaimer: C#'s what I earn my money with. That article confuses the hell out of me.

Why would you ever yield return a single value?

Why is the class name in lowercase/camelCase for 'networkSocket'?

Why are the method names following the (.Net standard) PascalCase convention in 'networkSocket', but using the (Java et al) camelCase in the samples below?

In my opinion this doesn't show a thing about the stack from the title and the C# is (arguably of course) a little messy. Even ignoring the inconsistent style (catching "Exception" comes to mind, public fields instead of properties, etc).

2 comments

Why would you ever yield return a single value?

Thats a special case in the Unity game engine as the Update() functions of each script are called in the Game loop once per frame. Now if you do a WWW Request without yielding out of the game loop, the game will hang in that frame until the WWW Request is finished. By yielding it does the WWW Request asynchronous outside of the game loop and comes back to the Debug statement when the WWW Request is done.

I share your view on the incosistent Code Style though, it should be PascalCase all the way and i have always done it like that in Unity projects.

Public fields are another thing special to Unity, as you are able to modify public fields directly within the IDEs Object Inspector, which allows you to modify values while testing the game for example. You can also use Properties but those wont allow you said Inspector modifications (at least in Version 3.x that was the case).

Well, first of all thanks for your feedback.

The article is the first part of a series that will highlight our technology stack as we are developing it. The HW for indoor positioning, the algorithm, the twisted server and the chef recipes will all be highlighted in the incoming posts.

For what concerns the rest, you are totally right. I have been googling around to see how to hack a tcp channel to connect our Unity client to the twisted tcp server and I could not find anything. The documentation is kinda lacking, so I put together a naive prototype with the intention of sharing it for whom might have similar needs.

I will polish the code and post the highlights of the rest of the stack soon enough