From the course: Unity 5: Build a Character Dialogue System

Unlock the full course today

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

Create the JsonFactory

Create the JsonFactory - Unity Tutorial

From the course: Unity 5: Build a Character Dialogue System

Start my 1-month free trial

Create the JsonFactory

- [Narrator] Now that we have our images, our JSON file, and our narrative event class all set up, we can create a factory script that will read data from our JSON file, and map it to a narrative event. Back in Unity, I'm going to create a new C# script by right-clicking, Create, C# Script. I'm going to name this JSONFactory. Go ahead and open this up in MonoDevelop, and clear out everything except the using directives. Save that off. We want to consider what we're going to be using this class for and what architectural decisions make the most sense. So let's start with some constraints. We need a list of our JSON files and their file path extensions. Only the Narrative Manager script should be able to call the JSON factory class. That script is something we'll be working on later. Last, the class should act as a black box, taking in a scene number, and returning a narrative event object. Whatever script we initialize, or call the factory class from, should have no idea how or what is…

Contents