Introduction

This page will go through the flow of import from a csv file to Unity, and the creation and modification of databases and their C# classes.

We use Notion as an example, but any tool capable of giving you a csv file should work similarly.


Database set up

All databases must be named DB_[DatabaseName], with DatabaseName being a unique identifier. The first three letter of that identifier become the id of the field.

If two databases share the same first three letter, you can add the first three of the next word.

When choosing a name for your database, avoid names that are often already used in code (like DB_Event , or DB_Texture would be bad names as both event and texture are common type in C#. You can rename them to something like DB_EventVillage or DB_VillagerTexture)

Ex :

DB_Villager : Identifier → Vil

DB_EventVillage : Identifier → EveVil

<aside> ⚠️

If two databases have the same name, when you import them in game, they will be understood as the same type, and imported as such. If you want to split your databases, or make a backup of them, as long as you have the same identifier they will be recognized as the same.

</aside>

Fields

Each field that is supposed to be read by the game must have its name starting with the database identifier, and have a unique name. When naming a field, avoid names that are already names for something in C# (like Vil_Type would not be valid, as type is something that already exist in C# for objects.)

Two fields cannot be named the same way. Field names should not have any space between words.

If you want to add a field that should not be read by the game, add a ! in front of its name.

Ex:

Vil_Weathers → list of weathers for the DB_Villager (Vil identifier). Read by the game.

!SetWeathers → references to the weathers page for DB_Villager. Not Read by the game.

Supported Types

Supported types with no extra set-up

Types needing extra-steps

Necessary fields

All databases must have the first field (the name field in notion) renamed to [DatabaseId]_Id

Ex: DB_Villager → Vil_Id.

This identifier is what will become the name of the object in game, and is unique to each.

Some database have other fields necessary, and will be detailed in their respective section. They are by default already coded in game.

Adding new fields

To add a new field to a database that will be read by the game, you need to first create the field following the naming convention. Then it needs to be created in game.

<aside> ⚠️

You can use the field, and import the csv, even before the new field was created in game. It will simply not be read yet.

</aside>

You then have two options. Either manually edit the C# files (located in [Village Framework Location ] > Village > Scripts > Village.Database > Generated by default), or using the C# file generator.

For both, see Modifying and Adding Databases.

Databases

For the Village Framework to work by default, some databases are necessary. Each of these databases also have some fields that are obligatory and will be detailed here.

You can find the database we used for our demo scenes and that can be used as template in Database Example.

DB_Chapter

DB_Choice

DB_Commodity

DB_Destination

DB_Effect

DB_ItemStack

DB_Inventory

DB_Item

DB_Opportunity

DB_Spawnpoint

DB_Villager

DB_Weather

Adding new databases

To add a new database that will be read by the game, you need to first create the database following the naming convention. Then it needs to be created in game.

You then have two options. Either manually create the C# files (located in [Village Framework Location ] > Village > Scripts > Village.Database > Generated by default), or using the C# file generator.

For both, see Modifying and Adding Databases.


Exporting

Your export method may change depending on where your data is stored, but here are the two common scenario we use.

Notion export

Open the page you want to export.

  1. Select the view you want to export (You can use filter to only export a part of the database, to make import faster)
  2. Open the menu on the top right of the page
  3. Click on Export

ExportNotion1.jpg

  1. Select “Markdown & CSV” and click “Export”
  2. Select a location and a name for your zip file.

This will give you a zip file, containing another zip file and inside two .csv.

  1. Extract both zip

  2. Rename the file you want to import to just leave the database name (here, DB_Villager)

    <aside> ⚠️

    The difference between the two file is that the one with _all at the end has all the fields , even those hidden by the view you select. The other only contains field visible from the exported view. Select the one you prefer.

    </aside>

image.png

image.png

image.png

Google sheet export


Importing to Unity

To import a csv file to unity, you need to open your unity project, and go to Tools > Village > Village Window. This will open the Village Window.

Its composed of 3 tabs. First, check the settings, to set the location of the files to generate.

Settings

Modifying and Adding Databases