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.

--

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

.NET Core on Jenkins in Docker series 3/4

AWS VPC Summary

Package your Lambda function as a container image

Comparison Inheritance And Polymorphism in JAVA

Setup Multi Node Kubernetes Cluster

Apache Superset Security Implementing Using Keycloak

17 programming languages you need to know in 2016

Rebuilding My Home Server for 2020 (Part 2)

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
Matthew Clark

Matthew Clark

Unity Game Developer and C# Programmer

More from Medium

Game Maths — Cross Product

Introduction to Physics in Unity

Coding a Player Controlled Starship in Unity 2021

Creating A Cooldown System in Unity