|
|
|
|
|
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). |
|
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).