Skip to content

NathanGuilhot/Unity-ImportExport-CSV-SO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity - Import/Export CSV and ScriptableObject


This editor script provide an way to generate multiple ScriptableObject from a CSV file, and to export them back into a CSV if you've made changed in the editor.

This script allows the fast iteration of ScriptableObject, while not requiring for designers to manage and install Unity. This can really benefit heavy data games like RPGs, deckbuilders or Roguelike.

This repo also include a turn based combat system that serve as an use case for this script:
managing game elements such as items and enemies both through CSV and the Unity editor

Turn based combat demo

  • The two editor script you're gonna need to edit are the CSVItemImport and the CSVItemExport. There, you'll be able to list the SciptableObject you want to import/export.
  • The configuration for the CSV and ScriptableObject location is in the CSV class
  • The static class CSV contain the parser to go back and forth between a CSV file and a list of dictionnaries that will be used by the ScriptableObjects
  • Every ScriptableObject must use the IDataObject interface
    • The init() function act as a constructor, and must validate the data and raise the flag isValid if everything initialized correctly
    • A unique field id must be present so that we can easely reference objects between sheet (that's the only required field in your CSV)
    • GetData() is used for exporting: it return the data used for the initialization, but by changing the field that could have been edited in the inspector
  • To help you, I created a minimal template for your ScriptableObject. You can also refer to the two example class, ItemSO and EnemySO.

Optional utilities

About

Generate multiple ScriptableObject from a CSV file, and export them back into a CSV

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published