level importer

Introduction

Throughout the two last game projects, I have been working on the level importer between the level editor (Unity) and our game engine. The level importer, as a whole, contains two separate parts. One part in Unity, written in C# where the user can export a whole scene into a .json file and the prefabs existing in the repository. The other part using C++ to extract data from the .json file into the engine. 

Details

  • Worked on the level importer during two game projects

  • Written in C# and C ++

  • Uses RapidJSON library
     

Highlights

  • Easy debugging with .json files

  • Supports parent/child hierarchy

  • Features local changes made on prefabs in a scene

Progress

In the first game project, we used the level importer the game engine didn't support hierarchy so the level importer didn't. But as we started the second game project we soon realised the need for hierarchies and I iterated on the level importer to support it. Below are two screenshots of the same spot in the level, in Unity and the engine. As shown, the level importer can handle hierarchies. 

Unity

crashunity.png

Engine

flarecrash.png

Export scene

With a simple click on a button in Unity, the user can export the active scene to .json. The exporter script can detect when a local change in a prefab is made and export the prefabs in the scene .json file. The exporter script can easily be replicated to components which make it highly useable. The scene exporter also takes into account if there are any hierarchies in the scene. ​

import scene

The level importer in the game engine has a corresponding list of components to which component are exciting in Unity, but it also supports loading of engine specific components sush as splash component. The UI system also uses the level importer to launch the menus. 

Example of a component in unity 

spriteunity.png

Export prefab

The user can export all of the prefabs in the repository with a click of a button. The prefab contains all of the data the engine needs to create a prefab in-engine. 

import prefab

An imported scene is full of prefabs which the level importer loads from different files depending on which prefab should be used. In-engine, a programmer can easily spawn a prefab from everywhere in the engine since the level importer is a static class. 

further development

In the next project, I want to make the level importer faster by converting the file format from .json to binary.