Nerd For Tech
Published in

Nerd For Tech

Saving Data in Unity

For my insurance app to work it will need to be able to save data about previous cases. To do this I will need to save each case as a file.

The first step is to make a new case with the information of the current case.

The next step is to create a new file to write all the information in.

I needed to use the System.IO namespace to work with the files and the namespace System.Runtime.Serialization.Formatters.Binary to convert the information to binary to be able to write it to the file.

The next step was formatting the picture in a way that I would be able to store it in the file. I did this by saving the picture as a byte array that could be reconstructed to display the picture.

When the picture is taken I saved the path that it was stored to. When the data is processed I make a texture 2D image with the picture data and convert that to a PNG. The PNG data is what is saved to the active case file.

To display this on the overview panel I recreated the picture and cast it as a texture.

When I click the submit button it will now create a file for the saved data.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store