Import & Export

The Import/Export system allows you to import and export parts of your inventory system database.

This process does not create databases but rather it modifies an existing database. This feature allows you to quickly add groups of items or keep a readable data table of your items for use outside of Unity.

Note that the capabilities of the importer and exporter are limited. Not all data can be exported in a readable format. Unity Objects, Custom Recipes, and most Attributes are not supported for import and export.

This feature should NOT be used to make backups of your inventory database. We recommend using version control or a proper backup solution for database backups.

By default the Import Export system uses a CSV Import Export Module that imports and exports parts of the Inventory System Database

With the CSV Import Export Module you may choose the keys for the columns and other parameters to customize the format of the exported and imported data.

The Import Export Module is a Scriptable Object so any changes made to it will be saved. It is recommend that you make a duplicate if you plan to use this feature often to prevent values from being overwritten when updating the asset.

The exported data will look something similar to:

Item Categories

Item Definition

Crafting Category
Crafting Recipe
Currency

 

This feature is particularity useful for importing large sets of Item Definitions or Recipes. All keys other then the main key (“ITEM CATEGORY”, “ITEMDEFINITION”) and the name key are optional when importing data. Therefore if you wish to change the attribute value of many item in one go this can be a good solution (the attribute value must be of a supported type: int, string, float, etc.).

Note that the existing objects in the database will never be deleted on import. They will either be added if they do not yet exist or they will be modified if the data in the imported csv is different.

This Manager allows you to create your own Import Export Module by inheriting the ‘Import Export Module’ class.

/// <summary>
/// The Import Export Module is a scriptable object used to import and export data from a database.
/// </summary>
public abstract class ImportExportModule : ScriptableObject
{
    /// <summary>
    /// Export the inventory system database.
    /// </summary>
    /// <param name="database">The database to export.</param>
    public abstract void Export(InventorySystemDatabase database);
    
    /// <summary>
    /// Import the inventory system database.
    /// </summary>
    /// <param name="database">The database to import.</param>
    public abstract void Import(InventorySystemDatabase database);
}

Refer to the CSV Import Export Module source code for examples on how objects can be imported/exported.