A simple google spread sheet importer for unity.
You can import a google spread sheet and use it as a data source for your project.
- Open the Unity Package Manager
- Click the + button
- Select "Add package from git URL..."
- Enter
https://github.com/witalosk/UnitySpreadSheetImporter.git?path=Packages/com.witalosk.spreadsheetimporter
- Open your Google SpreadSheet
- Click "Share" button
- Click "Get shareable link"
- Get the id from the link (e.g. https://docs.google.com/spreadsheets/d/1X2Y3Z/edit#gid=0, the id is 1X2Y3Z)
- Get the sheet gid (e.g. https://docs.google.com/spreadsheets/d/1X2Y3Z/edit#gid=123456, the gid is 123456)
- Use the
SpreadSheetImporter
class to import the data
public class TestScript : MonoBehaviour
{
[SerializeField] private string _spreadSheetId = "1X2Y3Z";
[SerializeField] private string _sheetGId = "123456";
[SerializeField] private int _headerRow = 1;
[SerializeField] private int _dataStartRow = 2;
[SerializeField] private int _primaryKeyColumn = 1;
private async void Start()
{
var data = await SpreadSheetImporter.GetSpreadSheetDataAsync(_spreadSheetId, _sheetGId, _headerRow, _dataStartRow, _primaryKeyColumn);
foreach (var row in data)
{
Debug.Log($"[{row["Name"]}]: Price:{row["Price"]}, Note:{row["Note"]}");
}
}
}