This blog will cover the basics of serialization and the three most common methods of serialization in Unity: JSON, XML and Binary.
Serialization is the process of converting an object into a form that can stored or transported easily.
Objects are instances of classes and they are converted to a stream of bytes. This stream can then be stored as a file, saved onto a database or sent over internet to a web service.
The reverse of this process, converting a stream which can be a file or a string into an object is called deserialization.
It's easier to understand it using a simple example. In this example, the player details need to be saved, so that when the players replays the game, the details are already available to them. They don't need to provide it on every game session.
When the player inputs his details into PlayerData object the state of the object is serialized and stored as a file. In the next play session the saved file is deserialized to recreate or clone the same state of our object. JSON and XML are two common standard serialization formats and both of them are shown in the image below. These standards have their own pros and cons and will be discussed later.
Serialization is used extensively by the unity game engine itself for things like saving data of MonoBehaviours and scriptable objects, editor scripting, prefabs, instantiation, saving and loading your scenes etc. This post will only focus on the use of serialization that you may encounter in a game.
Uses of Serialization
JSON is the most preferred data exchange format for the internet. Web browsers and servers continuously use JSON to communicat between each other.
JSON Serialization and Deserialization
XML Serialization and Deserialization
JSON vs XML
Binary serialization converts and object into a binary format, which is a byte stream.
Binary Serialization and Deserialization
This blog post covers how emergent gaming tools and technologies have been used to make high-fidelity defence simulation, including LVC (Live, Virtual and Constructive) simulation which is the way ahead for most military simulators.
The LVC Simulation was done atop a high-fidelity terrain reconstruction which was mapped in-house via a Drone operation. The high-fidelity, one-to-one scale terrain already had about 30times the resolution available from Google earth, and was then made interactive and compliant with an LVC Simulation architecture where troops and tanks could train simultaneously. The concept was successfully demonstrated and highly appreciated, as part of CII & Indian Army’s Seminar on Simulation, conducted by the Army Design Bureau.
This is part 2 and concluding post on the entire exercise, and part 1 covers the aerial mapping of the terrain via a drone here.
High fidelity synthetic terrain recreation
The attached graphic illustrates the entire pipeline of constructing the high-fidelity terrain for the simulation exercise. Major parts are further explained below.
The image below, shows the synthetic terrain (virtual) constructed via the above pipeline.
This is a two part blog post. Part 1 talks about the background to the entire exercise, the Part 2 talks about the simulation exercise which was built on top of the entire Drone Op generated data.
The background to this entire operation were our simulation activities that we were doing for Defence. Our past experience had mostly been with the Indian Air Force, and recently had also done some aviation simulation works for the Indian Navy. However when we demonstrated the same to the Army, the feedback given was ‘Well, all this simulation, terrain recreation etc is fine for aircrafts flying thousands of feet above the ground, but we need something which can give a soldier a feeling of if he has the boots on the ground’. This needed a very highly accurate ground mapping which required two elements – a digital elevation map (known as DEM) and ground texture.
Now DEMs were available, but those in the public domain had extremely low resolutions, only suited for very high-altitude passes, like those available from NASA and Japan Space Systems. Higher resolution DEM imagery is either available only to military (including ISRO’s own DEM data – but we didn’t have access to that), or very expensive to buy for commercial use.
Google earth (including Pro) pack – while allowed you to export imagery, it didn’t allow you to export the elevation, and even imagery had to be stamped with Google earth’s logo. And the resolution wasn’t good that we wanted anyway.
The target that had been give to us for the textures resolution was – 10 cm per pixel. A massively ambitious target. But audacious goals only embolden us to achieve them. We decided, we’d get our DEM via an aerial survey.
Choice of platform
In order to do an aerial DEM, we obviously needed an unmanned aerial system (UAS), or commonly known as – Drone. There were many choices and factors
Learning to fly
Saving and retrieving data is something that every Unity Developer has to struggle with at some point of time. By the nature of how Unity and how computers work, most of your data change is volatile. Even changes made in Editor Play mode are not permanent.
We need to save data in order to track progress and record important values, which are critical to the gameplay.
Data is lost between scenes because on every scene load Unity will destroy previous scene’s game objects, except when it’s explicitly specified. This in turn leads to destruction of MonoBehaviours and thus the data.
Data is lost between gameplay sessions because the memory allocated on RAM for a Unity application at run time is freed up by the OS when application is closed.
So the problem of saving and retrieving data can be broadly classified into two categories
Scene to Scene
In part 2, methods of saving data permanently will be discussed.
Guardians of the Skies, the official game of the Indian Air Force was launched about two years ago, and has gone on to be downloaded more than 3 million times, and won a couple of awards. Here is looking back at its story, which not only captures how it came into being and what went behind the scenes, but also a brief 'coming-of-age' of the small team which made it.
You can get the game for Android, iOS and Windows.
Why do we make games ?
Games are supposed to be an escape from the reality, in a world of dreams. Where we can be what we wanted to be before we got caught up in the daily grind.
On behalf of team Threye, allow us to share our first Virtual Reality game, something which we've been working across the year 2015-16, coming from the genre of aircraft simulators, you can enjoy missions like takeoff from aircraft carrier, land on sea/ground, engage enemy aircrafts etc.
The current aircraft and missions available are based on a Mig29, it is planned to add more aircrafts, and more scenarios in future.
Meanwhile, please grab the beta here and give it a spin. For best experience, use a VR HMD and a joystick, but it works on standard PC with keyboard and gamepad as well.
The official game of the Indian Air force - Guardians of the Skies, since its first release in July 2014, has gone on to achieve a total of more than 2 million downloads across various platforms, it has been featured on app stores across the world, and also won awards under Best-app and Best-game categories.
We'd like to express our kind gratitude to all the patrons who've downloaded and played the game, and for those who wish to paint the sky with the Tricolour on the event of India's Independence Day on 15 August 2015, a special limited version of Guardians of the Skies has been uploaded on the Google Play Store with the mighty Su30 of the Indian Air Force in the Indian Tricolour Livery.
We hope that Guardians of the Skies has helped you feel the pride and the thrill of flying for the Indian Air Force, and hope that you continue to aspire to touch the sky with glory, and to help you keep close to that aspiration, are attached a few wallpapers to grace your screens.