From the course: Unity: AR Visualization 02 Basic Interactivity

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

How to define data in Unity

How to define data in Unity - Unity Tutorial

From the course: Unity: AR Visualization 02 Basic Interactivity

Start my 1-month free trial

How to define data in Unity

- [Instructor] Data can be stored in many ways within Unity. You can use methods like scriptable objects, text files, JSON files, or PlayerPrefs. We're going to use serializable classes which is like a combination of all those methods mentioned. Serializable classes are C# classes with some special attributes. These attributes allow the class variables to be exposed within the editor. They also, as the name suggests, allow for them to be serialized. In this case, we'll be serializing and deserializing these classes to and from JSON. The JSON serialization is needed to store the data outside of Unity. Here, we will be taking our serialized string and storing it in PlayerPrefs.

Contents