Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GData

This is google sheets to class mapper

public class GameDataAsset {
    [GTable("ENEMIES")] // this can be ommited if GTable attribute is present of Enemy class
    public Enemy[] enemies;
}
[GTable("ENEMIES")]
public class Enemy {
    [GColumn("NAME")] public string Name;
    
    // This will be mapped by Enemy->Loot column using Loot's Index field
    [GColumn("LOOT")] public Loot Loot; 
}
[GTable("LOOT")]
public class Loot {
    [GColumn("NAME"), GIndex] public string Name;

    // GConverter used for defining field-level converters. It also can be defined on Rarity Class
    [GColumn("RARITY"), GConverter(typeof(RarityConverter))] public Rarity Rarity;
}

public class RarityConverter : IConverter<Rarity> {
    Rarity Convert(string value) {
        return new Rarity(value);
    }
}
DataSource ds = new DataSource(
    "...", // api key (create here: https://console.developers.google.com/apis/credentials)
    "..."  // spreadsheet id
);
EntityLoader loader = new EntityLoader(ds);
GameDataAsset asset = loader.Load(typeof(GameDataAsset)); // Recursively loads fields 
List<Enemy> enemies = loader.Load(typeof(Enemy)); // Loads all entities by class

GameDataAsset instance = new GameDataAsset();
loader.LoadToInstance(instance); // Loading to existing instance

About

Google Sheets to C# classes mapping library

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages