https://github.com/neronmoon/gdata
Google Sheets to C# classes mapping library
https://github.com/neronmoon/gdata
game-data game-development google-sheets-api mapper
Last synced: 3 months ago
JSON representation
Google Sheets to C# classes mapping library
- Host: GitHub
- URL: https://github.com/neronmoon/gdata
- Owner: neronmoon
- Created: 2019-11-29T23:15:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-07T13:33:12.000Z (over 5 years ago)
- Last Synced: 2025-01-14T19:04:18.329Z (5 months ago)
- Topics: game-data, game-development, google-sheets-api, mapper
- Language: C#
- Homepage:
- Size: 2.99 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GData
This is google sheets to class mapper```c#
public class GameDataAsset {
[GTable("ENEMIES")] // this can be ommited if GTable attribute is present of Enemy class
public Enemy[] enemies;
}
``````c#
[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;
}
``````c#
[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 Convert(string value) {
return new Rarity(value);
}
}
``````c#
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 enemies = loader.Load(typeof(Enemy)); // Loads all entities by classGameDataAsset instance = new GameDataAsset();
loader.LoadToInstance(instance); // Loading to existing instance
```