So this happened:
Screen Lock and Cursor lock defeat my lightbox qued from unity implementation. varied standards across browsers. abort. abort.
I’ve been working on hooking up Unity5 HTML and WordPress for a while now. I had it on the back burner for a bit while Unity5 release it’s own JSON utility. So far I’ve learned a few things:
- Unity5 JSON utility barely handles nested JSON data.
- Unity HTML5 and any JavaScript on the page can easily talk to each other. For example, I was able to make a trigger in Unity call a function in jQuery in another script on the same page. That same jQuery script was able to pass data into Unity. Ping Pong.
- There’s a lot of disparities between browsers for handling pointer lock.
- There’s disparities between browsers when handling ‘pointer lock’ that make it difficult to control. This killed the lightbox approach. I think I’ll wait a while before trying to toggle between unity’s html canvas focus and the rest of the page seamlessly.
The first point – basically, working with nested json data using unity5 json utility is maddening. I’m accustom to PHP or javascript for example where traversing nested data is no big deal. I even tried the Bekwnn’s simple JsonHelper to cherry pick the nested items. While that approach has legs, it was a lot of work and logic code to grab simple nested data.
cherry picking data snippets.. this is too much work
Long story short it’s not so easy in C# with this tool. It just can’t get at some nested data by conventional means. So I decided to change my approach. I’m using the WordPress JSON API and PODS to package the json data as before, but instead of connecting unity directly to the json data I wrote a tiny plugin to massage said json data into a unity friendly structure Unity then requests the data from a URL provided by the plugin. Essentially the plugin flattens all the post’s data into a single transversable object and packages it for Unity.
data from wp-api is grabbed by the WorldPress translator, consumed, and translated into a suitable format for Unity’s JSONUtility to parse (without catching on fire).
Back in Unity, things are swell for Unity’s new json parser. I was able to write a couple classes to model the data, and the data is stored into Lists (not arrays.. serialization drama).
With the data in lists inside Unity.. well sky is the limit. In this world I’ve spawned a grey ‘post’ object that contains all it’s WordPress post data.
This shows the flow of data from WordPress thought the plugin, to unity, and manifesting as tall grey ‘posts’… get it? hah eh..
So the fun beings… what’s possible when you can control the data of virtual world though WordPress?
WorldPress (WordPress JSON API + Unity3D + HTML5 / WEBGL)
Source:http://bunnygun.com/2016/03/12/worldpress-wordpress-json-api-unity3d-html5-webgl/