Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Google Sheets For Unity Lite

Discussion in 'Assets and Asset Store' started by Novack, Mar 3, 2014.

  1. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    There is no public doc. The included developer guide has integral parts of he asset so making it public is not easy. You can read the asset description in the store. this thread is a great source of info, and if you have any specific questions, of course I can help you with them. Cheers!
     
  2. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    On more question ;-) From within the editor, when you retrieve a table how and where are the data saved ? You talked about structs in you first answers. But is there an asset, a prefab, a ScriptableObject that hold those struct to make those data saved in the project ?

    Thanks
     
  3. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello again Kiupe,

    Im afraid the answer to that question, is pretty much the same than my original answer.
    Structs are a memory structure in C# language used to encapsulate variables. What to do with the data retrieved into those structs, is up to you. And it should be: the asset cannot asume any particlar need or usercase from that point on.
     
  4. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
  5. caglarenes

    caglarenes

    Joined:
    Jul 9, 2015
    Posts:
    45
    Hello, I bought your asset with May Madness Sale. It's working very good. Thanks a lot.

    I setup all client and server side instructions and example codes work perfectly.

    But I didn't understand one simple thing. When I use "GetTable()" or "GetObjectsByField()" function it returns nothing because it's a void function. How can I reach list or array etc. my data? I didn't catch where that functions send the data I want?
     
  6. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello @caglarenes, thank you!

    The methods you point do not have a return value, because the calls to the cloud service are async. That avoids your app to freeze until getting the response from the cloud.

    What you do instead, is to subscribe to events that are raised when the data has been retrieved. Look in GSFU_Demo_Runtime class, for an example. On the method OnEnable() the example is subscribing to the event, and will redirect the data to the method GSFU_Demo_Utils.ParseData(...) that will parse it, and do whatever is needed.

    Hope it helps!
     
    Last edited: May 19, 2018
  7. caglarenes

    caglarenes

    Joined:
    Jul 9, 2015
    Posts:
    45
    thanks a lot @Novack for your reply !

    I totaly understood the idea. This asset is some kind a tutorial for me now. :)
     
  8. marpione

    marpione

    Joined:
    Apr 16, 2016
    Posts:
    26
    Hi, I'm so frustrated with this. I took your ParseData and copied to my script. My script runs in editor so I made may own struct changed the neccesary thing and I added a listener for my method. I made a button and call a table from that button. When I subscribe the callback listner to my parse data (which is almost excectly the same.) I get empty info. But when I subscribe it to yours I get the full list. What am I missing? please help me with that.
     
  9. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello @marpione

    The example included with the asset should give you a clear cut of how Google Sheets For Unity is supossed to work, but not necesarily will work as a drop-in solution in your own code. You need to understand the asset code flow, and then use the approach that better suit your needs.

    By your description, what your getting looks like a flawled logic flow and/or some bug along the chain of changes. You should be able to track the issue down by debugging, etc.
     
  10. dhindman

    dhindman

    Joined:
    Jan 28, 2016
    Posts:
    17
    Hey @Novack, I recently came back to a project that is using this asset and noticed its no longer working. The following is the error output to the console with debug mode on:

    Undefined server response:
    <!DOCTYPE html><html><head><link rel="shortcut icon" href="//ssl.gstatic.com/docs/script/images/favicon.ico"><title>Error</title><style type="text/css">body {background-color: #fff; margin: 0; padding: 0;}.errorMessage {font-family: Arial,sans-serif; font-size: 12pt; font-weight: bold; line-height: 150%; padding-top: 25px;}</style></head><body style="margin:20px"><div><img alt="Google Apps Script" src="//ssl.gstatic.com/docs/script/images/logo.png"></div><div style="text-align:center;font-family:monospace;margin:50px auto 0;max-width:600px">Authorization is required to perform that action.</div></body></html> Time: 0.4523788
    UnityEngine.Debug:Log(Object)
    CloudConnectorCore:UpdateStatus(String) (at Assets/CloudTools/GSFU 2.0/CloudConnectorCore.cs:385)
    CloudConnectorCore:processResponse(String, Single) (at Assets/CloudTools/GSFU 2.0/CloudConnectorCore.cs:374)
    <ExecuteRequest>c__Iterator0:MoveNext() (at Assets/CloudTools/GSFU 2.0/CloudConnector.cs:75)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    Notice the "Authorization is required to perform that action." bit. I double checked all of the setup requirements and everything looks good; all is as it was when the project was working and deployed earlier this year. I also noticed that using the link in the developer guide that is supposed to take you to the google script is now leading to a google sign in screen for your company.

    I think Google may have made some changes to their API's recently and I'm wondering if they could have broken the asset. Any thoughts on this?
     
  11. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello there. I know that recently google has changed some permission requirements when you're using a script not writen by yourself. You may need to redeploy the script as webapp to make sure all permissions are correctly set.

    Regarding the link to the script, I just checked and works as expected. You may want to copy the link instead of clicking it on thr PDF, sometimes it fails depending the PDF engine.
     
  12. dhindman

    dhindman

    Joined:
    Jan 28, 2016
    Posts:
    17
    Ah, that was it. When I redeployed the app I had to review some permissions again and allow them. All is well now. Thanks a bunch!
     
    Novack likes this.
  13. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Is this plugin still working + supported + continued?
     
  14. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Yes. Dayjob and family time has not allowed for much recent changes (as a desired patch release), but its perfectly working and Im doing support as usual.
     
    Cascho01 likes this.
  15. JuanMaldonado

    JuanMaldonado

    Joined:
    Oct 12, 2012
    Posts:
    30
    Hi @Novack. Is there an quick way to make the spreadsheetId string public and not a fixed value to access different spreadsheets upon request?
     
  16. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello @JuanMaldonado

    Sure thing, the spreadsheet id is a parameter, and is sent to the webservice as such, is just a mater of using different one whenever suits you. In the code, you have it as a field in a class, but you can change that to whatever you need.
     
    JuanMaldonado likes this.
  17. JuanMaldonado

    JuanMaldonado

    Joined:
    Oct 12, 2012
    Posts:
    30
    Had the same problem when unloading and loading again the scene, so I set the CloudConnector instance to DontDestroyOnLoad.
    Code (CSharp):
    1. void Awake() {
    2.    DontDestroyOnLoad(this);
    3. }
    Hope this helps for someone else :)
     
  18. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hey peoples!

    I finally got some time to work on this, and I've decided to design a new asset related to Google Sheets for Unity. The underlying concept and main purpose would be the same, but able to work more broadly for Google Drive, not just spreadsheets.

    Google Drive for Unity is coming!

    Im planning some new features, a review of the entire logic, and likely will pack all the current Cloud Tools as different example cases.

    Will have news soon!
     
    Last edited: Dec 24, 2018
    caglarenes and sfoust like this.
  19. camran91

    camran91

    Joined:
    Feb 7, 2016
    Posts:
    2
    Hello,

    I've been trying my best to teach myself this process through your demo. It's been going okay but I'm at a dead end. I was able to run the demo, and it's amazing what it can do. I am tying to get it to read and output all my "researchers" names an emails. It recognizes that there are 18 names and emails, but it doesn't display their names or emails in the console, only name: email: 18x. Is there not a way to have it so it shows -> name: Jessica A Email: Jessicaa@mail.com 18x with different names and emails? The point of this is to create a list of names and a list of emails for a sign in, so that as people get hired/fired all I have to do is update the Spreadsheet and not the program. Sorry if this is simple, it;s going over my head if it is!
     
  20. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello @cjgibson, indeed you should be perfectly able to do that.

    The example uses a demo struct on the unity side code to represent the objects (rows) stored on the spreadsheet. You need to create a new one (or modify the one from the example) to match your table fields and then you will be able to request data from the spreadsheet and iterate over it to access all members, and if you want to, output it to the console.
     
  21. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Upcoming Google Drive For Unity is progressing real nice, rewrote the asset, already added files and folders handling, merged (re-implemented) CloudConsole and CloudImages basic ideas, improved access concurrency, added more examples, and the API has grown in options and flexibility!

    Also, I've decided that Google Sheets For Unity and maybe CloudImages will likely remain on the Unity Asset Store, but most probably the rest of the CloudTools will be deprecated (not confirmed yet).

    I need to work on a custom registration/login implementation example that is based on CloudPlayer, and after that... will likely be working on the feared WebGL support! Wish me luck ;)

    Stay tuned!
     
    Last edited: Jan 3, 2019
  22. camran91

    camran91

    Joined:
    Feb 7, 2016
    Posts:
    2
    Thanks for the reply! I'm looking forward to the Google Drive For Unity asset. Another question for you. For my job, they have a "tracker" in google sheets, and the headers I would need to use are in row 4 (Unfortunately I'm not allowed to edit the tracker's format). I can't figure out how to have it look for headers in row 4 and not row 1. Is that possible? I.E. row 4 contains the case numbers, case statuses, researcher names, due dates, notes, etc, which is what I need access to and how I would read and write to the sheets. Rows 1-3 are useless to me as they're just formatting. Also, is there an easier way to contact you or is this forum the best place? I may end up with a ton of questions as I make this program for them.
     
  23. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    You can't do that out of the box with the asset, but you do have the source code to the webapp service. There is where you would need to mod the service in order to recognice the 4th row as fields headers instead of the first one. Obtaining the headers should not be much of a change, but then requesting the "data range" to make other operations could be more complicated, depending the the case.

    It is likely that would be easier for you to work with the Unity client app on a different sheet, and then import the data to the tracker. Of course, I can only especulate, Idont know the case, but you'll need to find a creative approach.

    As for communication, the forums are good, but in the documentation you have the support email address.
     
  24. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Upcoming Google Drive For Unity is progressing real nice, though longer than I expected.

    I just finished implementing session context based queries: so despite the new library includes the stateless queries approach I did on Google Sheets For Unity, will also offer a login session (including registration), with a token and a session context similar than CloudPlayer does.

    Next step is... working on the dreadful WebGL support!

    If I can manage to pull it off, I'll make sure to back port that to Google Sheets for Unity ;)
    Hope to have news soon.
     
  25. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    New version is feature complete! Loads of improvements and new stuff. Will make a post describing it in full asap.
    I have decided to keep using the name "Google Sheets for Unity" rather than "Google *Drive* for Unity"...

    This one, "Google Sheets for Unity 2" will still be available, but as a Lite version, while the new one, fully featured will be the main.

    Need to work on a post describing it, documentation, presentations stuff, store stuff... will get back to you soon :)
     
  26. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Oh right everyone!

    I've decided to keep using the "Google Sheets For Unity" name for the new asset, and rebrand this version as the "Lite" edition.

    As such, the asset will remain on the Unity Asset Store. Read here to find about the new full version, which coming very soon!

    Other related assets from the Cloud Tools will be affected, will have news soon.
     
  27. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Ups, forgot to mention some of the features on the new version:
    • Rewriten codebase: improved query responses, client flow, connection data handling, authentication, access concurrency.
    • Sending and receiving files & folders (text, binary and image files).
    • Improved and extended API, in some cases with frequent requested options like accessing specific cells on spreadsheets (battleship game style).
    • More and better examples.
    Just no name a few, check the announcement forum post more details.
     
  28. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Heads up! The new main version of Google Sheets For Unity has been released :)

    Check the new asset details:
    [Forum Thread]
    [Store Page]

    Note that this version will remain published as the lite version.
    Cheers!
     
  29. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Oh right, some updates.
    Right now Im working on some improvements to CloudConsole which will be free now.

    After that, Im going to back port the underlying rework done on the new version of Google Sheets For Unity, to this one (which is now the "Lite" edition). In regards to that, I've decided to keep it clean and simple regarding the feature set differences:
    • Lite edition will remain focused on Google Spreadsheets.
    • Full version includes more Google Drive capabilities like handling folders and files.
    As such, the whole revamp, the major important changes as the improved API, server changes and some architectural tweaks will benefit both versions, as they will share the base code, and essentially one will be a subset of the other.

    Will keep you posted.
     
  30. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Ok Cloud Console is up for grabs already!
    If you're interested, is a good companion for Google Sheets for Unity, as you will already understand some principles used.
    Get it for FREE!
    [Store Page]
    [Unity Forum Thread]


    Now to the matter that is relevant for us here, Im gonna start working on the version of GSFU that we treat on this thread. Is going to receive the full codebase revamp done on the main version, and as a result some interesting new features will be available! (webgl, wink, wink).

    I'll keep you posted!
     
  31. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Aaaaand is Up! :)

    Google Sheets For Unity is updated for FREE for existing owners!

    This is internally the 3.0.1 version, but comercially branded Lite edition to denote its difference from the new asset.

    Check the exiting Changelog:

    • Codebase updated to match the full version architecture.
    • Now it works with WebGL.
    • Refactored connection data handling.
    • Refactored server responses to return pure json.
    • Added API methods for individual cell I/O.
    • Added localization example.
    • Added Editor Console log example.
    • Server script updated for better concurrency handling.
    • Added option for batch-creating objects.
    • Added option to UpdateObjects() for creating if not found.
    • Moved away from singletons for the connections.
    • Added prefab for simplicity of use.
    • API Reference is public now.
    Also, the list of asset public methods can be found online: Public API Reference.

    *What is the difference with the main version?

    The original version has been rebranded "Lite" edition, to denote the difference with the new asset.

    The new version encompasses wider use cases, including and extending capabilities that used to be scattered among 3 or 4 other assets (siblings from GSFU, that I named "CloudTools"). Makes available features for Google Drive files and folder management, images, a mimic for stateful sessions, among other thingies.

    In essence, the Lite version focuses exclusively on Google Spreadsheets, while the main version goes a bit beyond.

    Check out the demo!

    Enjoy!
     
    Last edited: Jan 31, 2019
  32. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    After being contacted on support about this, I reckon that I should be reminding people of an important remark: for developers already using this asset, have in mind that the 3.0 version:

    • Is API breaking (not harsh, though dont expect all methods to just work).
    • The server side script changed, it needs to be copied and deployed, old webservice wont work with the new version.

    All this will be worth once you note the new features and improvements on the new version ;)

    Cheers!
     
  33. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Did you know...? (Tip)

    Is well known (and evident) that Google sheets for Unity works with private and public spreadsheets from the Google Drive account owner.

    But, it also works with any spreadsheet, no matter the google account, if the sheet is public! This can be seen on the online demo, where you can provide your own spreasdheet and the example will let you work on it!

    Check out the WebGL demo for yourself!
     
  34. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Did you know...? (Tip)

    A leftover from the research required to circunvent cross-origin resource sharing or CORS (which was necessary for making the asset work on WebGL), is an undocumented feature: you can have server responses on JSONP format.

    If for some reason you need the server to answer in JSONP, all you need to do, is add a "callback" field to the POST form (with any content), and the server will return in the mentioned format :)
     
  35. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello people!

    March marks the Google Sheets For Unity Lite 5th year on the
    Unity Asset Store!



    To celeberate I'have been be offering FREE keys all week on my Twitter account. Follow me to keep up on news on tools and gamedev general topics.

    Thank you for so much interest along the years!
     
    Last edited: Mar 15, 2019
  36. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Final Lap! #GoogleSheetsForUnity 5th birthday celebration week: last day!
    Here is another free voucher key for Google Sheets For Unity Lite: ASV-4YD3-MX7R-3QPA-YWQ3-CKKH

    More to come today, on Twitter.
     
    Lars-Steenhoff likes this.
  37. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Heya everyone!

    Please keep in mind to rate & review the asset. I would be more than greatful the effort.
    There have been a few bad reviews on the past months, mostly related to rejected refund requests.

    I dont grant arbitrary refunds; persons who speculate, or realize after buying that they didnt bother to read the description are not reasonable imho. So I dont usually give on that, but the backslash is the expected price to pay. Some of them even go to the point of saying "it works, but didnt give me the refund", so go figure...

    So! Any help on that front, will be greatly appreciated.
    If you used the asset, find it good and useful, please consider making a review :)

    Thanks!
     
  38. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Check this out:


    Isn't that cool? :)

    I have been wanting to share this Google Spreadsheets not-so-well-known feature, for its potential good use with Google Sheets For Unity: there is a simple localization example included with the asset, that could adapt this in no time!

    Some guys on Twitter, beat me to document it, so Im just sharing the video obtained from this thread:
    https://twitter.com/papa_fire/status/1111994073609633792
     
    Lars-Steenhoff likes this.
  39. jebalsaad

    jebalsaad

    Joined:
    Sep 7, 2016
    Posts:
    9
    Hi there,

    Using this plug-in, can I upload data to the sheet and execute formulas then download the results without signing in. best,
     
  40. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm not sure... but if your purpose is just to have some way to execute formulas at runtime, there are probably better (faster) solutions.
     
  41. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    @JebAI I will be back at the studio later today catching up with all the pending correspondence :)
     
    Last edited: Oct 1, 2019
  42. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    @JebAI sorry for the delay, yes you can get the result of formulas on the spreadsheet. You can also set formulas on the spreadsheet too.

    You can test this on the online public demo. First set a spreadsheet id, create a worksheet using the demo button for that purpose, and then use the "Individual Cell Operations" section to test this.

    You'll be able to retrieve values resulting from formulas on the spreadsheet, or also setting formulas. Ie:
    1)
    upload_2019-10-1_10-14-46.png
    2)
    upload_2019-10-1_10-15-29.png

    The no-login requirement is part of Google Sheets For Unity main feature set, so that part is covered by default :)

    Hope it helps!
     
  43. ronshalev3d

    ronshalev3d

    Joined:
    Apr 30, 2019
    Posts:
    21
    does it work with APKS on VR devices?
    dows it matter at all to the GSFU module on which android it runs (AR, vr headset, mobile phone etc)?
     
  44. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello @nirharpaz3d thanks for contacting.
    It shouldnt matter at all :)
    The asset will work on any UnityWebRequest supported plataform. Currently enumerated as:
    • All versions of the Editor and Standalone players
    • WebGL
    • Mobile platforms: iOS, Android
    • Universal Windows Platform
    • PS4 and PSVita
    • XboxOne
    • Nintendo Switch
    Hope it helps!
     
  45. ronshalev3d

    ronshalev3d

    Joined:
    Apr 30, 2019
    Posts:
    21
    I have encountered another issue with your google sheet module.
    after retrieving the raw JSON, the parsing have failed and the wrapper. array I get from the ArrayFromJson function is null;
    I can bypass that using SimpleJSON or other method but since the demo worked alright i wonder if it was me who did something wrong.

    I have this sheet
    sheet.png
    and i've created this struct
    public struct UserInfo
    {
    public string WorkerName;
    public string WorkerID;
    public string Finished;
    public string Time;

    }


    In HandleDriveResponse, since I only use GetObjectsByField, I removed the rest.

    // Processes the data received from the cloud.
    public void HandleDriveResponse(Drive.DataContainer dataContainer)
    {
    Debug.Log(dataContainer.msg);

    string rawJSon = dataContainer.payload;
    Debug.Log(rawJSon); //this one logs perfectly
    // Check if the type is correct.
    if (string.Compare(dataContainer.objType, _tableName) == 0)
    {
    // Parse from json to the desired object type.
    UserInfo[] users = JsonHelper.ArrayFromJson<UserInfo>(rawJSon);
    Debug.Log(users); //this one logs null
    for (int i = 0; i < users.Length; i++)
    {
    _userData = users[i];

    }
    }
    }

    public static T[] ArrayFromJson<T>(string json)
    {
    string newJson = "{ \"array\": " + json + "}";
    Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(newJson);
    Debug.Log(wrapper.array); //this one logs null
    return wrapper.array;
    }


    any idea what might i have done wrong?
    I've made sure that the names of the fields in the struct and sheet are the same

    update:
    ialso tried to take the JSON from the working demo and parse it your way
    *(i deliberatly changed the names to caps cause I chancged it in the rest of the script as well and it worked well in the demo)

    i've created a test script like this
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. namespace GoogleSheetsForUnity
    5. {
    6.     public class testingtest : MonoBehaviour
    7.     {
    8.         public string jsonToParse;
    9.  
    10.         public struct PlayerInfo
    11.         {
    12.             public string Name;
    13.             public int Level;
    14.             public float Health;
    15.             public string Role;
    16.         }
    17.         PlayerInfo _playerData = new PlayerInfo();
    18.  
    19.         // Use this for initialization
    20.         void Start()
    21.         {
    22.             Debug.Log(jsonToParse);
    23.             PlayerInfo[] players = JsonHelper.ArrayFromJson<PlayerInfo>(jsonToParse);
    24.             Debug.Log(players);
    25.             for (int i = 0; i < players.Length; i++)
    26.             {
    27.                 _playerData = players[i];
    28.                 Debug.Log("<color=yellow>Object retrieved from the cloud and parsed: \n</color>" +
    29.                     "Name: " + _playerData.Name + "\n" +
    30.                     "Level: " + _playerData.Level + "\n" +
    31.                     "Health: " + _playerData.Health + "\n" +
    32.                     "Role: " + _playerData.Role + "\n");
    33.             }
    34.         }
    35.     }
    36. }
    and typed the output json from the demo:
    [{"Name":"michael","Level":45,"Health":"","Role":""}]

    it also yielded null so clearly there is something wrong in this proccess comparing to the flow in the demo.
    what's not identical?
     
    Last edited: Oct 7, 2019
  46. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    @nirharpaz3d I cant quite identify whats failing with the parsing, but sounds like you changed the code quite a bit. I would say the easiest way to get back on track is to start from the stock demo which works fine, and start changing things from there, until you get the error, then debug whats going on.

    Sorry but Im a bit blind from this side concerning what may be failing on a code with fairly few changes from your part.
     
  47. ronshalev3d

    ronshalev3d

    Joined:
    Apr 30, 2019
    Posts:
    21
    that's strange,and son't feel like i changed anything
    in 1 hand there is the stock demo that works fine and prints the raw JSON along the way.

    on the other hand, what you see here is basically a string variable that stores the printed JSON and should skip straight to the parsing with no change using the same struct you used originally.

    I can verify that the error happen in
     JsonHelper.ArrayFromJson
    in line 23.

    Code (CSharp):
    1. public static T[] ArrayFromJson<T>(string json)
    2.  
    3.         {
    4.  
    5.             string newJson = "{ \"array\": " + json + "}";
    6.  
    7.             Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(newJson);
    8.  
    9.             Debug.Log(wrapper.array);  //this one logs null
    10.  
    11.             return wrapper.array;
    12.  
    13.         }
    the function
    JsonUtility.FromJson
    fails for some reason.
    the question i have for you, is how would you suggest to check it cause it's clearly an input issue.
     
  48. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    You did changed code though, you mention it yourself:

    1) mentioned that changed HandleDriveResponse.
    2) mentioned that changed the json parser to SimpleJSON.
    3) mentioned that changed the demo class to use your own structure.
    4) mentioned JsonHelper.ArrayFromJson "in line 23" which does not correspond with any call of that function on the original codebase.

    So it seems quite simple, if it works before your changes, change it back (or start over) tracking down where it breaks as you add changes, as a matter of simple debugging.

    I mention this, because I dont recall to have seen issues like you describe before. It may be an issue with the asset, but why I dont clearly see, so until we can find an issue actually happening with the stock demo, one that I can reproduce, I dont see much help that I can offer!
     
  49. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    More to the point that the issue is related to your changes, check this bare minium example:

    Code (CSharp):
    1. using GoogleSheetsForUnity;
    2. using System;
    3. using UnityEngine;
    4.  
    5. public class NewBehaviourScript : MonoBehaviour
    6. {
    7.     private string _rawJSon = "[{\"name\":\"michael\",\"level\":45,\"health\":\"\",\"role\":\"\"}]";
    8.  
    9.     [Serializable]
    10.     public struct PlayerInfo
    11.     {
    12.         public string name;
    13.         public int level;
    14.         public float health;
    15.         public string role;
    16.     }
    17.  
    18.     private void Start()
    19.     {
    20.         PlayerInfo[] players = JsonHelper.ArrayFromJson<PlayerInfo>(_rawJSon);
    21.         for (int i = 0; i < players.Length; i++)
    22.         {
    23.             Debug.Log("<color=yellow>Object retrieved from the cloud and parsed: \n</color>" +
    24.                 "Name: " + players[i].name + "\n" +
    25.                 "Level: " + players[i].level + "\n" +
    26.                 "Health: " + players[i].health + "\n" +
    27.                 "Role: " + players[i].role + "\n");
    28.         }
    29.     }
    30. }
    It works just fine. So JsonHelper.ArrayFromJson is working as expected.

    Hope it helps.
     
  50. ronshalev3d

    ronshalev3d

    Joined:
    Apr 30, 2019
    Posts:
    21
    Oh i'm sorry for not writing clear enough
    i'm checking your example right now

    edit:
    after tweeking back and forth i clearly have no idea what was changes so i can't really reproduce.
    what's real is that it is now working as intended so TYVM!
     
    Last edited: Oct 8, 2019
    Novack likes this.