Search Unity

[Released] G2U 2.1.13 - Use Google Spreadsheets in Unity

Discussion in 'Assets and Asset Store' started by Shane-C, Oct 14, 2013.

  1. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Unfortunately not. When retrieving column headers from Google, they implicitly rename them to remove spaces, underscores, and converts them to lower case. They even rename duplicate column names to something_1, something_2, etc. This all happens before GoogleFu gets ahold of it, so I can't tell in code that it's been changed.

    Your best bet. Use Unique, lowercase column names.

    Shane
     
  2. Symyon

    Symyon

    Joined:
    Nov 26, 2012
    Posts:
    31
    Thank you Shane for a prompt answer!
     
  3. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    Hi,

    When I try to import my sheet, I receive this message: "Duplicate column name (void) please check your column names for duplicate names."

    The thing is that I use more than one "void" column, like in your documentation.

    What should I do to ignore more than one columns?
     
    Ash-Blue likes this.
  4. SeriousRPG

    SeriousRPG

    Joined:
    Oct 21, 2013
    Posts:
    7
    I have a question about this product or future plans. I noticed this product connects to Google for spreadsheet access. I am looking for a plug in that will allow me to create a Google doc (word processing) from a template stored on a google drive, update the document and save it back to the google drive, through Unity. I am not sure if I can use some of this API for that and am looking for some direction (or whether you plan to expand your connection to be able to get a doc rather than a spreadsheet. I am new at this type of interface so I am not sure if there is something about Unity that prevents this.

    Thanks for any info/feedback you can give me.
     
  5. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    While a lot of the same methods are used in the authentication side of things, GoogleFu focuses on Spreadsheets and not the Word Processing documents. GoogleFu wouldn't be helpful at all in your requirements and currently there are no plans to expand the functionality of GoogleFu to include Word Documents.
     
  6. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    This is a legitimate bug, and we'll have it fixed for the next release. In the meantime, use "Ignore" in the type rows and name your columns something unique.

    Thanks for reporting the bug!
    Shane
     
  7. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Version 1.0.13 has been submitted to the Asset Store.

    Notable improvements:

    1.0.13
    Fixed JSON output bugs (Thanks imtrobin)
    Fixed Playmaker code generation when using void/ignore rows and columns (Thanks ghost012)
    Generated Databases and Row classes now implement Interfaces for getting the String data in an effort to increase generic usage. (Thanks -JohnMore-)
    Improved authentication and workbook regeneration speed. (Use Auto-Login.. it's faster! Finally!!!)
     
  8. Wyldcard

    Wyldcard

    Joined:
    Feb 28, 2014
    Posts:
    2
    Hi Shane,

    Great bit of kit, it's taken a little while to get my head round it but that's probably lack of coding skill on my part.
    I'm currently looking at using this as a bit of a workaround for my problem, so far it looks like it might work.

    I was using flashbuilder to pull through a csv and put that data into a 2D array, it worked fine but now the bosses want to make the project web-based(a bit of heads-up would have been nice) Flash + Web = NO!

    So, checking out G-Fu as a way of bringing that data in, then interrogating.
    Currently I can bring in a whole row or column and that's nice enough but I need to interrogate in a cell by cell manner.

    Can you think of any good ways to do this with G-Fu, or is it a case of back to the drawing board?

    Any thoughts you have would be greatly appreciated :)

    Thx
     
  9. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Hey there Wyldcard,
    All of the data from the workbook is pulled into the database at once. How you decide to access the data is up to you. GoogleFu gives you a few different options to retrieve the data, but once you get to the row level, you can iterate over the data however you like. If there is a specific way you would like to retrieve the data and you can't seem to figure it out, please email the details to contact@litteratus.net and I'll guide you in the right direction.
     
  10. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    I'm still getting the null bug mentioned earlier for columns, really need a fix for this as our team has a lot of notes built into our Excel sheets. Deleting that info just to import would be horrible.

    Also btw, Ignore in the row type is not working for me
     
    Last edited: Oct 27, 2014
  11. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Ash, Email me and send me a link (or copy) of your spreadsheet so I can repro with the exact dataset, we'll take care of this as soon as I get home.
     
  12. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    @Shane C Sent you a message with some mock and thank you. My issue occurred on a Windows machine if that makes any difference.
     
  13. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    Well I feel stupid. It suddenly started working when I got home and turned on my computer (literally nothing changed in the DB). Thanks @Shane C for testing the file I gave you, I would rate this thing 6 stars at this point if I could.

    I think I was getting a cached version from Google's API where I accidentally had duplicate column names. Thanks so much for the help.
     
  14. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    No worries! Glad it's working for you
     
  15. mspro79

    mspro79

    Joined:
    Oct 29, 2014
    Posts:
    4
    Hi Shane.
    I have two google account. I was logged in as one of the two accounts and clicked the "Refresh Workbooks" button.
    I had to change to the second account and log in again.
    I pressed the "Refresh Workbooks" button but the worksheet list does not change anymore.

    what should i do to reload worksheet list?
     
  16. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Bouncing between accounts can be troublesome, A better practice would be to share workbooks between your Google Accounts.. I have never experiences the workbooks getting stuck though. I recommend logging out through GoogleFu entirely, and logging back in again. If that doesn't work, Log out, close and re-open Unity, and Log back in again. Perhaps a persistent object got stuck. Like I said, I haven't personally encountered this bug, so I'm just shooting in the dark this time.

    Shane
     
  17. mspro79

    mspro79

    Joined:
    Oct 29, 2014
    Posts:
    4
    Thank you for answer.

    Has not been resolved yet. Attach the two screenshots. I hope this helps.

    1) Google.GData.Spreadsheets.SpreadsheetsService "_Service" has a second account.
    upload_2014-10-29_23-0-2.png

    2) However, finds the "entry.Feed.Title.Text"(first account) in the "workbooks".
    upload_2014-10-29_22-59-29.png
    Thank you for your reply once more.
     
  18. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    I am going to have to investigate this further. In the meantime a workaround would be to share the workbook you are trying to access with the other account. I'll report back when I find a resolution to this.
     
  19. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    I have identified the issue and have a fix available. If your GoogleFu.cs is unmodified, open it up and change the following lines:

    GoogleFu.cs : 147
    Code (CSharp):
    1. From:
    2. var savedToken = GetString("AuthToken", string.Empty);
    3.  
    4. To
    5. var savedToken = GetString("AuthToken_" + _Username, string.Empty);
    GoogleFu.cs : 156
    Code (CSharp):
    1. From:
    2. SetString("AuthToken", token);
    3.  
    4. To:
    5. SetString("AuthToken_" + _Username, token);
    I will get the packaged updated and submitted to the Asset Store shortly.
    Thanks for the bug report!
    Shane

    EDIT: Version 1.0.14 solves this issue
     
    Last edited: Oct 29, 2014
  20. mspro79

    mspro79

    Joined:
    Oct 29, 2014
    Posts:
    4
    Hi Shane

    I've updated the 1.0.14 version. It works very well..

    But pressing the "Refresh Workbooks" button then there is one kind of error.
    or generated by pressing the "Activate" button.

    It works well, but the error.

    Thanks so much for the help.
     
  21. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Hmm.. I just tried switching accounts, refreshing workbooks, activating, deactivating, switching again... Everything looks stable on my end. No errors at all. A 500 Server Error could mean just about anything. I don't think it's directly related to GoogleFu. I think perhaps you should wait a few hours and try again.. perhaps the Google server was overloaded?

    Shane
     
  22. mspro79

    mspro79

    Joined:
    Oct 29, 2014
    Posts:
    4
    Hi, Shane

    Your comment was right. Now it works fine.

    Thanks so much for the help.


    Um... I have one thing more questions.

    Do you plan to support for "ArrayMaker" of PlayMaker?

    Thank you for always.
     
  23. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    To be honest, I don't use Playmaker personally, so I had no idea this was a thing. I'll look into it, but it sounds like it should be possible to support it.
     
    Ash-Blue likes this.
  24. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    If you are using the Free version of GoogleFu, the Full Version is in the Birthday Bonanza sale for the next 10 days!
    Go grab your CHEAP ($3 USD) upgrade now!
     
  25. pchuri

    pchuri

    Joined:
    Aug 18, 2014
    Posts:
    12
    When I import the GoogleFu, the following error has occurred.
    How can I fix it?

    ===================
    Assets/GoogleFu/Editor/GoogleFu.cs(130,99): error CS0411: The type arguments for method `System.Linq.Enumerable.Where<TSource>(this System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,int,bool>)' cannot be inferred from the usage. Try specifying the type arguments explicitly

    Assets/GoogleFu/Editor/GoogleFu.cs(190,21): error CS1579: foreach statement cannot operate on variables of type `Google.GData.Spreadsheets.SpreadsheetEntry' because it does not contain a definition for `GetEnumerator' or is not accessible
    ===================
     
  26. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    pchuri: It looks like these errors have cascaded due to a problem with the input on the spreadsheet itself. Please email me at contact@litteratus.net and include a copy of the spreadsheet, or a link to where I can see it and I'll try to identify the problem.
     
  27. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi,

    I am trying to use GF to hold lines a quiz database, and I would like the first column to be a simple integer as an index, so my spreadsheet first column is set up as below:

    GOOGLEFU_ID
    int
    1
    2
    3
    4
    5
    6

    However, when I try to import this I get the following error:

    Found invalid starting character: ( 1 ) in word 1
    UnityEngine.Debug:LogError(Object)
    GoogleFu.GoogleFuEditor:IsValidEnumerationName(String) (at Assets/GoogleFu/Editor/GoogleFu.cs:5461)
    GoogleFu.GoogleFuEditor:IsDataValid(IEnumerable`1, IEnumerable`1) (at Assets/GoogleFu/Editor/GoogleFu.cs:5323)
    GoogleFu.GoogleFuEditor:ExportDatabase(String, String, WorksheetEntry, Boolean) (at Assets/GoogleFu/Editor/GoogleFu.cs:3619)
    GoogleFu.GoogleFuEditor:Export(String, IEnumerable`1) (at Assets/GoogleFu/Editor/GoogleFu.cs:1617)
    GoogleFu.GoogleFuEditor:DrawSelectAndExportGUI() (at Assets/GoogleFu/Editor/GoogleFu.cs:2182)
    GoogleFu.GoogleFuEditor:ToolboxGUI() (at Assets/GoogleFu/Editor/GoogleFu.cs:2325)
    GoogleFu.GoogleFuEditor:OnGUI() (at Assets/GoogleFu/Editor/GoogleFu.cs:2710)
    UnityEditor.DockArea:OnGUI()

    If I set the type to string I get the same result, unless I prefix the numbers with a letter.

    Can you help at all please?

    thanks,

    Nalin
     
  28. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Nalin: There are a few rules that you have to follow when setting up a spreadsheet. One of them is that you cannot begin an ID with a number. In this case the error states "Found invalid starting character: ( 1 ) in word 1"

    Use this instead
    GOOGLEFU_ID
    string
    ID_Q001
    ID_Q002
    ID_Q003
    ...

    You should be good to go then. Don't worry, you can still index the entries with a number. I'd recommend reading the documentation for the rules.. There aren't many, but they are important.

    Shane
     
  29. kirkbowe

    kirkbowe

    Joined:
    Oct 2, 2010
    Posts:
    6
    Regarding JSON export. I was kind of hoping that the ID (index) field would appear as the object name:
    ...
    "AI_GOBLIN": {
    "Name": "Goblin",
    "Level": "1", ...

    But instead I get:

    {
    "googlefu_id": "AI_GOBLIN",
    "Name": "Goblin"... etc.

    Is there a way to move the id field to become the 'object' name?
     
  30. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    The problem with JSON is there is no one "Right" way of doing things. I'm looking into giving the JSON export more options for the style of export, but without changing code there is no way of changing it at the moment.

    Dig into the Json Export function and rearrange how the data is being exported. If you get stuck, email me and I'll see if I can lend a hand.
     
  31. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Thanks for this - yep got it running :)
     
  32. gravyleaves

    gravyleaves

    Joined:
    Mar 19, 2014
    Posts:
    28
    There seems to be a problem with the Cambodian language. I'm not sure if it's a unity problem or googlefu problem. I've got a Khmer font installed but it looks all wrong in the editor.



    When I manually set the font in the inspector it looks good in-game although the text-box component looks the same as the picture above
     
  33. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    You are saying that in-game, if you use a GUILayout.TextBox, the font is displaying incorrect glyphs, but there is another case where the same string looks ok when you reference it from the GoogleFu database?

    If that is the case, then I'd say that Unity is incorrectly handling the font. GoogleFu is simply storing the unicode characters, and returning them when you ask for them. The Cambodian language isn't handled any differently than the other languages.
     
  34. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    As of today, the Free version of GoogleFu will be available exclusively from our website. This is in accordance to the Asset Store Terms of Service for restricting content in Free versions. We had a choice to make. We could strip features from the Free Version, or keep it the way it is, with the restriction on sheet exporting but pull it from the Asset Store. We chose the latter, as it gives everyone a full representation of the paid version, while still retaining the value of the paid version.

    You can find the latest version of the Free asset at http://www.litteratus.net/GoogleFu-Free.unitypackage
     
  35. Jon-Gao

    Jon-Gao

    Joined:
    Dec 9, 2012
    Posts:
    17
    Hello, I bought it few days ago. I can success read data. but just want to know, can I write data back to spreadsheet?
     
  36. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Rosa: Currently there are no plans to support writing information back to a Google Spreadsheet from Unity.
     
  37. Jon-Gao

    Jon-Gao

    Joined:
    Dec 9, 2012
    Posts:
    17
    Gotcha! thanks for answering :)
     
  38. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    Having some issues staying authenticated at the moment. GFu seems to log me out after about 30 seconds or whenever I change scenes, logging back in after that also seems to totally stall unity for a good 5 minutes or more (could you perhaps thread the authentication?). Updating 4 large workbooks use to take a few minutes, currently it's painfully consuming more than an hour.

    Apart from this issue Google Fu has been a really awesome and solid product.
     
  39. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Hmm.. Changing scenes shouldn't cause a logout. I'll look into that. The first time you log in it will take a bit, it's pulling all the information from your spreadsheets (The more you have on the account, the longer it will take.) I recommend using a Google Account specifically for the game that has the appropriate workbooks shared. This will keep the processing time to a minimum.

    As for threading, I'll look into it again, but I know it caused issues before. The Unity Editor isn't designed to handle threads, and GameObject access is forbidden.. but I have recently been working with background threads in C#, and I might be able to apply some of that to the GoogleFu login process, if Mono behaves the same in that regard.
     
  40. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    Having the login threaded would be good simply because without it you're disabling unity entirely, or at the very least add some kind of timeout. If you have a login issue like mine that's not resolving and you have auto-login on, you can't even kill the Unity process and start it back up again as GoogleFu will instantly start blocking for the auto login. At one point just to get some work done I had to actually delete the main GoogleFu plugin files from the project - not the best workflow to be sure.
     
  41. Rainking

    Rainking

    Joined:
    Jun 10, 2013
    Posts:
    41
    Hi,

    I bought your asset a while ago, since then I used it quite often (for i18n and data management). It helps a lot but now I run into an issue I can not solve by myself. This morning it stopped working because googlefu can not login anymore. So I created a new app password (since I use 2 step verification). But googlefu is not able to login... I reinstalled googlefu - no luck. I tried all the "old tricks" like rebooting ;) - still no luck. I use Unity Free version 4.60f3
    It worked before, so I suggest it not a problem with my credentials. (I made about 10 new credentials before I gave up). Do you know something about google changed the login API? My other apps are working fine with the generated passwords...
    Thank you and kind regards, Tino
     
  42. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Hey Tino, sorry I've been busy all weekend and haven't been able to check in.
    So you are saying you generated a new application password and it still won't log in? You are the only one who has reported this as being an issue, and I just set up a brand new 2 step authentication password and logged in myself just fine. So I don't think it's an API thing at all.

    Perhaps setting up a new account without two-step authentication and sharing only your Google Doc with the new account will solve the issue for you? If you still can't seem to figure it out, email me at contact@litteratus.net and I will help you troubleshoot it.

    Shane
     
  43. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
    Google seems to have changed how they handle what they call 'non-secure' apps like GoogleFu - you have to explicitly enable the functionality before GoogleFu will work. GoogleSecurity.jpg
     
  44. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
  45. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
  46. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
    Shane, question regarding JSON export. Is there any way to get the json exporter to properly handle things like int & float vars on export? currently everything in a json file is exported as a string (wrapped with double quotes), which causes issue when trying to load the objects directly via LitJSON or other object-mapping systems. I'd rather not have to parse individual fields & cast types etc when loading the data from the spreadsheet, causes an unnecessary transformation step that I'd rather avoid if possible.

    Example (copy-pasta'd from here: http://www.andrewnoske.com/wiki/Unity_-_JSON)

    Code (CSharp):
    1. public static void LoadJsonFromResourceFolder() {
    2.     string resource_path = "text/steve";  // Note that ".json" part must be left out.
    3.     TextAsset text_asset = (TextAsset)Resources.Load(resource_path, typeof(TextAsset));
    4.     if( text_asset == null ) {
    5.       Debug.Log("ERROR: Could not find file: Assets/Resources/" + resource_path);
    6.       return;
    7.     }
    8.     string json_string = text_asset.ToString();
    9.  
    10.     Person steve = JsonMapper.ToObject<Person>(json_string);        // Json string to object.
    11.     Debug.Log ("steve's name from resource file: " + steve.name);   // Outputs: "Steve Irwin"
    12.   }
    Assuming a json output of this:

    Code (JSON):
    1.  
    2. {
    3. "name": "Steve Irwin",
    4. "age": 44,
    5. "birthday": "02/22/1962 00:00:00",
    6. "pet": [
    7. {
    8. "name":"Sui",
    9. "type":2
    10. }
    11. ]
    12. }
    13.  
    It should be able to mapped to an object directly, however GoogleFu is exporting any numbers in the spreadsheets like this:

    "age": "44"

    and so on, ie as strings.

    Thoughts? Is this something that is considered for future releases?

    Note that I do have the 'type row' in all of my spreadsheets, but having a first entry in the json isn't very useful to be honest.
     
  47. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    The JSON output is so rarely used that our efforts really haven't been all that focused on it (With the exception of a few bug fixes here and there). If this is something that is needed, then we will certainly put it on our TODO list. We are already doing this in other places, but the JSON export code is an extremely simplified version.

    Our thoughts initially were that anything we do pre-export could just as easily be done at import time, and strings can't be screwed up by deserialization issues as easily.

    If you would like to be a guinea pig, we'll certainly work with you. contact@litteratus.net

    Shane
     
  48. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    128
    email sent ;}
     
  49. Magris

    Magris

    Joined:
    Apr 26, 2014
    Posts:
    4
    ArgumentException: An element with the same key already exists in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,System.String].Add (System.String key, System.String value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
    GoogleFu.GoogleFuEditor.ExportNguiLegacy (System.String in_path, IEnumerable`1 in_entries) (at Assets/GoogleFu/Editor/GoogleFu.cs:2771)
    GoogleFu.GoogleFuEditor.ExportNgui (System.String in_path, IEnumerable`1 in_entries) (at Assets/GoogleFu/Editor/GoogleFu.cs:2731)
    GoogleFu.GoogleFuEditor.Export (System.String in_workbookName, IEnumerable`1 in_activeEntries) (at Assets/GoogleFu/Editor/GoogleFu.cs:1647)
    GoogleFu.GoogleFuEditor.DrawSelectAndExportGUI () (at Assets/GoogleFu/Editor/GoogleFu.cs:2182)
    GoogleFu.GoogleFuEditor.ToolboxGUI () (at Assets/GoogleFu/Editor/GoogleFu.cs:2325)
    GoogleFu.GoogleFuEditor.OnGUI () (at Assets/GoogleFu/Editor/GoogleFu.cs:2710)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)


    I have this issue
    and can't save ngui .txt file

    how can i fix it
     
  50. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    We have solved this via email, but since the question was answered here I'll answer here as well.

    "An element with the same key already exists in the dictionary."
    GoogleFu is attempting to build a dictionary from the rows/columns, and this will happen if you have a duplicate row or column header in your spreadsheet.

    Also for everyone, the "Legacy NGUI" exporter has been deprecated, as the new NGUI has been out for a very long time and there should be no reason to be using the old version anymore. The next major version will not have the "Legacy" exporter any longer.
     
    Magris likes this.