From the course: Unity: AR Visualization 03 Complex Interactivity

Adding notes to the data structure

- [Instructor] Now that we've got notes added to the project, it would be really great if we could save them. So to do that, we're going to have to make one more data structure. Let's go grab our ARPartData and duplicate that. We're going to call this ARPartNoteData. Grab that name and open it up in your code editor. We have to make this additional structure because JSON serialization doesn't actually handle dictionaries. All we have to do here is make sure that we're saving a guid and a string. A guid itself cannot be serialized, so we're going to add that as a string as well. So let's go up here to ARPart, rename this to ARPartNoteData. And we're going to go and get rid of these. I'm going to call this guid. I'm also going to add another public string and call this note. That's all there is to this data structure. We now have to add this into our ARPartData. So let's go and open up our ARPartData. And we're going to have to add a collection underneath position. To do this, I'm going to make a list. But first thing I'm going to need to do when I make this list is to add the collections using. So let's go up here to system, duplicate that, go dot collections and generic. All right, so now we can make the list. Let's go and do that. And go public list of type new class that we just made, ARPartNoteData and call this notes. Great, I'm also going to initialize this. New ARPartNoteData. All right, fantastic. Now that we have our structures all set up, we're going to have to go an alter our load and save methods.

Contents