Posts

Showing posts from December, 2019

Unity3D JSON Serialization (save game data)

Image
Let's keep this short:
My BoxingDay activity was to create a small Unity3d project utilizing JSON serialization for saving game data. Basically, this sample project shows how to save and load game data in one serializable class.

Whole project is available at Github:
https://github.com/jliias/SaveData
(I believe it should work as such)



In this sample project I will serialize GameData class, that contains following variables:
bool adsEnabled
int coinsCollected
int highScore

These variables are packed and unpacked to text format using JsonUtility API that can be used to convert Unity objects to and from JSON format. Basically, it is possible to pack and unpack simple objects to text format by using this API (e.g. collections or arrays are not supported).

Serializing to JSON is done using ToJson method, and and deserializing using FromJson method.

It is important to add [Serializable] to the top of class that will be serialized.

This is very simple solution and as far as know this should …

Using Unity3D LWRP and shader graphs in real game

Image
My previous Unity3D post was demonstrating my trials with scriptable render pipeline and shader graphs. Now I have gone one step further and combined these techniques with one of my previously released game. "Ball Twister"was originally released about an year ago. I did not advertise it too much because of boring outlook and bit simple gameplay. However, now I have found this game perfect for testing scriptable render pipeline and shader graphs in real 3D environment. Attached video shows how different new version of Ball Twister looks compared to the original one. Original version (on left) is using standard Unity render pipeline and shaders. Enhanced version (on right) is using LWRP (or URP) and shader graphs.



In enhanced version, rolling checker board texture, swirling sky and obstacle materials are all using shader graphs to create a sense of movement just by tweaking textures. Basically, only objects that are really moved are black obstacles and coins. Everything el…