Data-driven Text101 engine for Unity 5

I made a data-driven engine for Text101. Rather than hard-coding a fixed number of states, I can now write any story with any number of states in a JSON resource file.

My starting point was the official serialization guide. The JsonUtility module was introduced in Unity 5, so I had to move the project to that.

The JSON data format has a couple differences from the C# objects’ format. JsonUtility can’t yet parse a JSON object into a dictionary, so in JSON any key/value collection must be an array instead. When the value type is an object, I make the key a member of the object. Otherwise, I store alternating keys and values in the array: [key, value, key, value, key, value, …]

Further ideas:

  • Story editor GUI (starting point)
  • Variables like time, money, etc.
  • AI of other characters: goals and logic for accomplishing them
1 Like

Not to take anything away from you building this, but if you were looking for something off the shelf, check out Fungus (story/conversation engine) on the Asset Store. http://u3d.as/f0T

Thanks, I’ll keep it in mind. Only doing this as an engineering exercise and sharing what I learn from it.

I now have an editor with basic functionality: add/remove states, and add/remove key commands to a state.

As usual I started by RtFM. From there it was a straightforward matter of looking up editor GUI elements and implementing them one after another.

Unlike the game engine, the editor just works with the story data as read from disk. I don’t feel a need to put the data into data structures for fast access, as the editor only handles one datum at a time, in intervals of seconds rather than milliseconds. This might change if I were to try making a very large game with it.

Privacy & Terms