Search Unity

[RELEASED] Google Sheets For Unity Lite

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

  1. William-Cain

    William-Cain

    Joined:
    Oct 19, 2012
    Posts:
    8
    So just be sure I am understanding this correctly, I am able to save NEW data into the google spread sheet, from the game client, into a new cell right? Meaning that if a new player comes in and adds his player name and then starts playing the levels and getting scores for the first time I can add these into the spread sheet right?

    Conversly I can then have a page with game stats that are pre-set and I can pull that data from the google spread sheet into my GameManager Object in Unity as variables and do what i want with them correct?

    If that is the case then I am buying this tonight. :)
     
  2. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Thanks for asking @William Cain. That is the case, yes. new data can be sent to the spreadsheet, as well as retrieved at any time.

    Should be noted two things I have come to learn advising:
    This is a tool oriented to development. Final released products may found security implementation insufficient, depending on needs. And also important to note, is that you must know coding, the example included is just that, your implementation may vary depending your own project.

    Thanks again!
     
    Last edited: Aug 23, 2014
  3. William-Cain

    William-Cain

    Joined:
    Oct 19, 2012
    Posts:
    8
    @Novack

    Thanks for the heads up, I think coding shouldn't be a problem. This will be a fantastic tool for balancing and development just like you said! Keep up the good work man!
     
  4. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Thanks mate!
     
  5. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Last night sent an update to the Unity Asset Store.

    Version 1.3 will update the LitJson version, which allows me to fix an issue found by @Antipirina where Unity would throw an error if cells in a worksheet row are left empty. Those using other json parser should not be affected.

    There is a new debugMode option flag in the connection object for a more verbose console output (useful for catching issues).

    I also included some polishing on the manual (thanks Anthony!), and replaced "sheet" by "worksheet" on the editor fields to avoid confusions.

    Will let know as soon as is up.
     
    Last edited: Aug 23, 2014
  6. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Ok, there was a record time aproval for v1.3 (thanks so much guys), but I found some things I should have changed from the released version. V1.3.1 has been submited, I will let know when is up and ready!


    Edit: Annnddd v1.3.1 is up! Thanks Asset Store fellas, you guys and girls are awesome!

    Get the update here: http://u3d.as/6Lk
     
    Last edited: Aug 23, 2014
  7. Greg-S

    Greg-S

    Joined:
    Mar 3, 2012
    Posts:
    7
    Hey. I was implementing GSFU and I went to go build the project to test something unrelated to it and got an error on build:
    Assets/GSFU/Scripts/GSFUEditorMenu.cs(1,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?

    If I move that script to the Editor folder, I get the same error on ContinuationManager.cs in the same directory.

    I investigated and any time using UnityEditor outside of something like a #if UNITY_EDITOR or script being in a Editor folder, it will error on build. I didn't see anything in the manual you included with the project about moving the scripts but if I threw both of them in an Editor folder, it will remove the error on build. Wasn't sure if this was a solution that would break anything since I haven't started using it yet, just downloaded it while I worked on other things.

    I'm building for iOS if that has an effect (shouldn't in this case).
     
  8. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Woah!

    Man, that was my mistake. Indeed, both ContinuationManager.cs and GSFUEditorMenu.cs should go inside an "Editor" folder. Thank you for leting me know.

    @Everybody: Im gonna submit an update asap to fix this silly mistake, but in the meantime: the solution is simply what @Greg S did, place both files within an "Editor" folder.

    Thanks, I will let know when update is up!
     
    shadabs22 likes this.
  9. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Oh right, faster update ever: GSFU Version: 1.3.2 (Aug 25, 2014) is up!

    Thanks again AssetStore girls and guys, awesome people :)
     
  10. Greg-S

    Greg-S

    Joined:
    Mar 3, 2012
    Posts:
    7
    Thanks for the quick update!
     
    Novack likes this.
  11. William-Cain

    William-Cain

    Joined:
    Oct 19, 2012
    Posts:
    8
    @Novack So I am, sure you have talked about this before, but exactly how unsecure are these google sheets from hackers. Say two examples: 1. spreadsheet of game stats that the game pulls from at loading and then uses in the game internally,etc. The google sheet would be private. 2. publishing the highscore sheet to a webpage that shows the results on an iframe. How easy would it be for someone to hack these google pages? Are there any plans for implementing more security in the future on this plugin?
     
  12. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    @William Cain thanks for bringing that up.

    Interesting topic, that I have been considering lately .

    The first thing is: precisely the simple out of the box security measures are what makes of this a more developer oriented tool, than something for published games.

    For one side, the call is being done using HTTPS (so wiretapping is unlikely), and the spreadsheet can be private, so that helps too, as the security is from Google itself.

    However the weak point is the url call, which includes the keyword for the script to authorize the operation. Whoever intercepts/inspects this call (using a local app or proxy), will have all the info he needs to access the web service, and thus, modify the sheet or get its content.

    This can be improved, but there are so many different use cases for a tool like this, that when I initially compared the cost of making a universally acceptable solution with the time it would delay the release... well, I picked simple security, and a released tool.

    I have been considering enhancing it though, as time has passed and the extention seems to be now picking up attention... it may be soon on the table.

    Any ideas or suggestions are most welcome!
     
  13. William-Cain

    William-Cain

    Joined:
    Oct 19, 2012
    Posts:
    8
    @Novack Hey I am trying to buy this package but it says that i need Unity version 4.6, there doesn't seem to be a version 4.6 at the moment.....
     
  14. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Oh, thats just another thing I was about to mention William, you seem to be tunned to my mind! :)

    The thing is that the Unity Asset Store takes my current Unity version to set the minium requirement for the assets I upload. In this case, Im using the 4.6 beta.

    However, Google Sheets for Unity works with any version of Unity backs to (at least) 3.x, basic or pro. So almost anybody can safely use GSFU without requirements issues.

    I expect to solve this asap, but need to download an old version of Unity, install, redo the project and re submit, and does not make for a good definitive solution, considering the Unity project format may have vary from 3 to 4, so I would have to mantain 2 separate projects... you get the picture!
     
  15. William-Cain

    William-Cain

    Joined:
    Oct 19, 2012
    Posts:
    8
    @Novack sounds good, I look forward to getting it.
     
  16. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    You should still be able to get it by the web browser store (website version of the store).
     
  17. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    That's the accepted practice currently. I don't think the unitypackage format has changed such that it won't work on 3, 4, or 5. It's basically a tar.gz file anyway.
     
  18. alienufo

    alienufo

    Joined:
    Feb 7, 2013
    Posts:
    1
    Quick question, does this let me modify existing cells in a spreadsheet, or does it only let me create new ones?
     
  19. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    @alienufo Sorry I did not noted your question before. Out of the box it only creates new ones. Not difficult to change that, depending on what you need though. You would be needing some javascript knowledge, and diving some bits into the spreadsheets API. Is another good case of example implementation to add though! I willl have it in mind, thanks you!

    @OnePxl I know its the current practice, but I would not say it is "accepted". ;)
     
  20. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Hi Novak,

    This looks like a pretty neat little extension here! Just querying a coupla things before I decide to purchase or not;
    I'm making an MORPG that's gonna be run in the Photon cloud. Unfortunately PhoClo doesn't store data in it, so I need somewhere else to save my players stats, inventory, health, last position etc, and a Google spreadsheet seemed like the easiest way. Is this plugin meant to access Google spreadsheets, or GDocs? And if so, how does it work (I know it uses WWW classes, but you can do that in normal code, so... does it make it easier, more efficient, or what?). Lastly, will it work with multiplayer?

    Thanks [;)]
     
  21. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hey @Bionicle_fanatic, on to the questions:

    1) Is this plugin meant to access Google spreadsheets, or GDocs?
    Google Spreadsheets! (I assume by GDocs you mean the Google Text Editor documents).

    2) Is this plugin meant to access Google spreadsheets, or GDocs?
    You could not use Unity's WWW classes to access a Google spreasheet, thats not how they work. You need Google API libraries and coding a solution on top of that. GSFU changes the approach, using a webservice script that gets deployed in your own GDrive, acting as a sort of proxy.

    3) Lastly, will it work with multiplayer?

    GSFU is independent from your networking setup, it will work or not depending entirely of how you handle it. If you mean about concurrent connnections, there should be no issue (Google Spreadsheets can handle it well), but again, will depend on how you manage situations of people accesing info while others are making changes, is a logic flow issue beyond the purpose or reach of GSFU.

    That being said, a couple of observations:
    * GSFU is a tool oriented to development, its current security scheme is not recommended for released games.
    * GSFU requires you to know what you're doing coding wise, as it is a sort of mini framework, you will be coding on top of it.
    * For what you mention, you need a database. Modern DB's handle all you need, plus they dont have GSpreadsheets limitations of amount of data. As a solution for development though (later on the project moving towards a DB), GSFU would be ideal.

    Hope it helps, thanks for asking!
     
  22. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Okay... I'm not too worried about the security level, but what do you mean about the plugin requiring knowledge of what I'm doing coding-wise? Do you mean, assign variables on a script specific to the plugin, or something like that?
    Also, Google Spreadsheets are technically mini-databases, so why do you think I'd need a whole new database?

    Thanks for the quick answer, BTW [;)]
     
  23. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    I mean, this is an script asset, not a visual tool, or art. It includes examples of how to use it, but requires you to program or tweak at your own needs. So its not really well suited for non coders.

    A database and a spreadsheet are very different things. Case in point, your own needs. Google "sql concurrency", and you'll see what Im talking about.
     
  24. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Oh, I don't think I'd have any problem with the coding side of things [:p] That's where I thrive [:p]

    Maybe, but it's still better than loading a text doc to the web and putting player info directly there [:p] Which was what I was originally gonna do [:p]

    Just one more thing ([:p]); Say my spreadsheet has the Y column taking in the player's names, and then along their X side are the stats (for example, last checkpoint). When someone runs the game, would I be able to load the last checkpoint for that specific player at runtime?

    Just checking, 'cause 20$ is kinda my whole funds ATM XP [:p]
     
  25. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hey @Bionicle_fanatic, sounds good then :)

    What you want to do sounds very much feasible, although you would need to tweak a bit the webservice script. Its Javascript -so dont worry about the language-, although you will need to dive a bit into the Google API for Spreadsheets.

    Check your inbox, I will send you a PM with some extra references.
     
    Last edited: Sep 5, 2014
  26. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    I know a lot of CSharp, and could probably convert the variables into a Java file to send to the GS.

    Thank you very much! [:)]
     
  27. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Back again [:p] Nothing major, just probably something I've done wrong (again [:p]). I started off small, trying to upload the player name and class to a GS. This is the code I call;

    Code (csharp):
    1.  
    2. stringconnectionString = webServiceUrl +
    3. "?ssid=" + spreadsheetId +
    4. "&sheet=" + statisticsWorksheetName +
    5. "&pass=" + password +
    6. "&val1=" + savedName +
    7. "&val2=" + savedClass +
    8. "&action=SetData";
    9.  
    ...So basically, just doing what the example did with different data to save. All the sheet names and IDs are up to scratch (I tested them with the example). However I get this error with a load of HTML, and in it this one particular line;

    "TypeError: Cannot call method "getDataRange" of null"

    I fiddled about a bit, and managed to get an error in french (? [:p]), and it was something like:

    "Le script est terminé, mais la valeur obtenue n'est pas un type de réponse compatible"

    ...Which I think means that it's not a recognized data value or something? I even tested it with the example spreadsheet (which works), but still the same error...

    It's probably something really simple that I've missed, but if anyone could give me a hand I'd be very grateful [:)] [:p]
     
  28. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    First, make the stock example work. This means to check the runtime option to send data to the statistics worksheet and see if it is actually working: play the scene, check the option, let the balls bounce a few times, then go to the spreadsheet, and see if the statistics worksheet gets the data as expected.

    If it does then something you're doing after that is wrong on your local code.
    If it does not, then something is wrong on how you setup the system (spreadsheet and webservice).

    Is a simple logic flow, as with any other debugging process.
     
  29. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    I did check the example, and actually saw the figures scroll across the scene [:p] Really quite amazing....

    It must be something I've done, I'll recheck the code tomorrow [;)]
     
  30. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    It works! [:D] It's incredible! [:D] And so fast! [:O] [:D] Brilliant plugin, Novak, 5 star! [:)]

    Just one thing; Do you know how to replace data on the spreadsheet? I need to update the player's inventory every time they log out, but at the moment I only know how to add data on a new line...
    If it's not possible to do that, then I could add a whole new line for the updated player, and just remove the old one, but I don't exactly know how to delete line using code either [:p] Is it something to do with the last perimeter of the connectionString ("&action=SetData")?

    Thanks very much for an amazing plugin [:D]
     
  31. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hey Bionicle, thaks for the praises for GSFU :)

    Currently, I have not included an example implementation for spreadsheet data update. It can be done for sure, but you will need to tweak, or rather enhance the webservice script, to handle that. Is javascript, so the language is not exotic, you just need to read a bit of the functions from the Google api for spreadsheets.

    At some point, I will include this example, but no idea when, at the moment I have too much work.
     
  32. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Ah, the webservice script... you mean the one that you upload as a web app? That shouldn't be too hard...

    Ah, I was looking through a huge list of functions I found in the spreadsheet sourcecode XD Thanks, I'll took them up [:)]
     
  33. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello @Bigpete591, please don't publish here contents from the manual.

    Please contact me by email for this issue, including the invoice number for the purchase. Thanks!
     
  34. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
  35. OceanBlue

    OceanBlue

    Joined:
    May 2, 2013
    Posts:
    251
    I have a basic use question. Am I right in thinking that if I have a Google spreadsheet containing values for different levels e.g. Level1-1, Level1-2, etc... that these can link with the variable of the level reference in Unity and Unity will store those values for the final game? Meaning that during development and play testing, we can tweak the values in the spreadsheet for game balancing?
     
  36. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hello @OceanBlue!

    The question looks somehow abstract at some points, but in general terms, yes, the idea behind GSFU is precisely that. Game balancing is one of the main potential uses!
     
  37. kurtslash

    kurtslash

    Joined:
    Nov 27, 2014
    Posts:
    1
    Hi i have a problem Data error: could not parse retrieved data as json, could you help me please.
    thank you, email please.
     
  38. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Kurtslash, I certainly need more info on the issue than the provided here. So, either you elaborate a bit here, or contact me by the support email provided in the package.
     
  39. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Have not received an email from you.

    What I can add, is that most often the error you mention is thrown when you're not authorized to run the script.

    Whatever you have done, something has failed along the chain of script-spreadsheet deployment.

    Best advide I can give you is to start from scratch. In the 90-95% of the support cases, the issue is related to an incorrect or missing step on the deployment procedure.

    Please check the manual steps as if you had never read them before. Is tricky because is so simple that people tend to not read carefully.
     
  40. btiger19

    btiger19

    Joined:
    Jun 28, 2009
    Posts:
    56
    Hi Novack

    Does the GSFU support to save json data from Google Sheet to Unity Project folders? Because we plan to adjust the data value on Google Sheet when developing games, but when we publish the game, we'd like to bake/save the Google Sheet data to local json file, so the published game do not need internet connection.

    Thanks.
     
  41. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Instead of having to save a whole .json file, why not just grab the data that you need from the spreadsheet and save it to PlayerPrefs? [;)]
     
  42. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,793
    I think @btiger19 wanted to bake the data in the final build and to distribute it to players. PlayerPrefs do not get distributed with the final build, unless I have missed something? :p

    An easier alternative to .json would be to embed the data in code if it isn't too large. In C# that would look something like:
    Code (csharp):
    1. using System.Collections.Generic;
    2.  
    3. static class MyGameData
    4. {
    5.     public struct DataRow {
    6.         public string col1;
    7.         public int col2;
    8.         public float col3;
    9.         public float col4;
    10.     }
    11.  
    12.     public static List<DataRow> Rows = new List<DataRow> {
    13.         new DataRow { col1 = "Somthing", col2 = 15, col3 = 11.3f, col4 = 0f },
    14.         new DataRow { col1 = "Something else", col2 = 42, col3 = 5.45f, col4 = 0.75f },
    15.         new DataRow { col1 = "Whatever", col2 = 0, col3 = 0.3f, col4 = 1f },
    16.     };
    17. }
     
  43. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hey @btiger19, currently GSFU does not takes care of persisting local data in a separate file. I have been considering adding a few more example use cases to the extension, and persisting local data in files is one of them, but due to time constraints this should not be expected any time soon.

    What you mention nonetheless is not particulary difficult to implement, and Unity provides classes and functions to write files IIRC.

    Thanks @Bionicle_fanatic and @Flipbookee for the comments! :)
     
  44. btiger19

    btiger19

    Joined:
    Jun 28, 2009
    Posts:
    56
  45. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Important Update!

    A recent change on the Google side, has slighlty affected the webservice, so I in order to fix it, I had to work on the script code.

    Anyone getting inconsistent/unexpected behaviours when writing TO a google spreadsheet, please do this:
    • Delete your current web service script from your Google drive.
    • Following the link from the extensions pdf manual, make a new copy of the script, reauthorize, and redeploy.
    • Change the settings of your connection object on Unity accordingly.

    In case of doubt following the above procedure, have a quick look at the manual again ;)

    Thanks, and sorry for the inconvenience!
     
    Last edited: Feb 24, 2015
  46. altheonix

    altheonix

    Joined:
    Oct 20, 2012
    Posts:
    19
    I always get this response
    "The script completed but the returned value is not a supported return type."

    any idea?
     
  47. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hey @altheonix I would need more details to be able to help you. Please write to the support email so you can elaborate on the issue.
     
  48. altheonix

    altheonix

    Joined:
    Oct 20, 2012
    Posts:
    19
    @Novack Sorry, never mind.
    I just wait several days and try again, it works. I didn't even change anything maybe google webscript was on a maintenance :) Thanks for replying.
     
    Novack likes this.
  49. adanlevy

    adanlevy

    Joined:
    Jul 29, 2009
    Posts:
    5
    Hi, is your tool in accordance with the Oauth 2.0 now that Google has forced to use it two days ago?
    Thanks!
     
  50. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Hey @adanlevy thanks for asking. GSFU does not use Google authentication, so its safe from changes on that regard ;)