/// <summary> /// Read a public accessable spreadsheet /// </summary> /// <param name="searchDetails"></param> /// <param name="callback">event that will fire after reading is complete</param> public static void ReadPublicSpreadsheet(GSTU_Search searchDetails, OnSpreedSheetLoaded callback) { if (string.IsNullOrEmpty(Config.API_Key)) { Debug.Log("Missing API Key, please enter this in the confie settings"); return; } StringBuilder sb = new StringBuilder(); sb.Append("https://sheets.googleapis.com/v4/spreadsheets"); sb.Append("/" + searchDetails.sheetId); sb.Append("/values"); sb.Append("/" + searchDetails.worksheetName + "!" + searchDetails.startCell + ":" + searchDetails.endCell); sb.Append("?key=" + Config.API_Key); if (Application.isPlaying) { new Task(Read(new WWW(sb.ToString()), searchDetails.titleColumn, searchDetails.titleRow, callback)); } #if UNITY_EDITOR else { EditorCoroutineRunner.StartCoroutine(Read(new WWW(sb.ToString()), searchDetails.titleColumn, searchDetails.titleRow, callback)); } #endif }
public void Load(WWW url, OnSpreedSheetLoaded callback) { if (string.IsNullOrEmpty(config.API_Key)) { Debug.Log("Missing API Key, please enter this in the confie settings"); return; } if (callback != null) { onFinishedLoading += callback; } if (Application.isPlaying) { Task t = new Task(WaitForRequest(url)); } #if UNITY_EDITOR else { EditorCoroutineRunner.StartCoroutine(WaitForRequest(url)); } #endif }
/// <summary> /// Wait for the Web request to complete and then process the results /// </summary> /// <param name="www"></param> /// <param name="titleColumn"></param> /// <param name="titleRow"></param> /// <param name="callback"></param> /// <returns></returns> static IEnumerator Read(WWW www, string titleColumn, int titleRow, OnSpreedSheetLoaded callback) { yield return(www); ValueRange rawData = JSON.Load(www.text).Make <ValueRange>(); GSTU_SpreadsheetResponce responce = new GSTU_SpreadsheetResponce(rawData); GstuSpreadSheet spreadSheet = new GstuSpreadSheet(responce, titleColumn, titleRow); if (callback != null) { callback(spreadSheet); } }
public void LoadPublicWorksheet(string spreadsheetID, string from, string to, OnSpreedSheetLoaded callback = null) { WWW www = new WWW("https://sheets.googleapis.com/v4/spreadsheets/" + spreadsheetID + "/values/" + from + ":" + to + "?key=" + config.API_Key); Load(www, callback); }
public void LoadPublicWorksheet(string spreadsheetID, string worksheetName, OnSpreedSheetLoaded callback = null) { WWW www = new WWW("https://sheets.googleapis.com/v4/spreadsheets/" + spreadsheetID + "/values/" + worksheetName + "!" + defaultA1Notation + "?key=" + config.API_Key); Load(www, callback); }