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. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    That's great to hear! :)
     
  2. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    476
    Hey Shane just tried to import a new workbook but I'm having a problem. Basically when I change the type to int G2U still asks for the data the start with a letter. Also as soon as I switch the type, the validate icon flickers like crazy. Any ideas? Thanks.
     

    Attached Files:

    • g2u.JPG
      g2u.JPG
      File size:
      116.5 KB
      Views:
      805
  3. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    The far left column is an ID column. It's used for variable names in code. This particular column must contain unique id's for each row, and one of the rules is that it must begin with a letter.

    In your case, you can simply use ID_0, ID_1, etc..
     
  4. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    476
    Thanks, I've been using G2U for ages but never realised this haha.
     
  5. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    This is... extremely surprising!
    Unless you are using the JSON export.. in which case there is an option for "Ignore ID column".. BUT it still must exist!!
    G2U keys off of it internally as well, and if it doesn't contain unique ID's, G2U gets very moody.
     
  6. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    476
    Yeah I'm using object databases and for each one I've done so far it's made sense to have the first column as a string ID.

    But for the one I did recently I thought I didn't need it and I would just access them via the order they are in, in the spreadsheet, e.g. .GetRow(0), or something. If that makes sense haha.
     
  7. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Heya!

    I've just picked up the asset and so far it seems quite nice! I was wondering though if there's a reason you store everything in a list as opposed to static variables? That way I could access a row like Dialogue.ID_0.English?

    I'm thinking about writing my own editor script to generate this, but I'm not sure how I can find the name of each column? You've stored rows, but not the column strings.
     
  8. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Hey Gumboots,
    The implementation can be easily changed. Each export type has it's own class and you can change it however you like. They are basically just code generators. We chose this method due to it being a lot easier to write the generators to work in all cases.

    The column names are the actual variable names in the MySheetNameRow class that is generated. (Prepended with an underscore to help prevent conflicts.. code generation is tricky)
     
  9. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Ah yes, that makes sense! Well I don't really want to fiddle around with your source, as it'll be overwritten in updates, so I'm going to make a second script to scrape the database you generate and just generate me a class for my uses.

    Is there anything special I need to do to make sure nothing from G2U ends up in my final build? As in, where can I put your generated database etc., so I don't store everything twice in a build?
     
    Last edited: Jun 15, 2016
  10. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Well it depends. Are you exporting as an Object Database? If so, you are going to have to make a new exporter because all of the data ends up in a GameObject in your scene. If you are using a static database, then there is 1 class that is generated as a file. There is one (tiny) base class that the Object Database relies on, that is included in the final build, other than that the only things that ship with the product are the files you generate from G2U. None of the other code/resources are included whatsoever.

    Honestly I've been considering rewriting the way I handle exporters, so if you want to write your own, I'll make sure to work with that in mind, and try to make it as painless as possible to update. Just make sure you write your own class.
     
  11. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    No worries! In case you're interested, I'll pop what I wrote below. It runs through the Unity assembly and finds any classes that implement IGoogle2uDB. Of course it's quite specific to my requirements (every sheet needs to have the same columns, e.g. "English", "French" etc., but can have different rows). It generates one base class, which is a 'row', essentially. And then creates static variables for each row of each spreadsheet, separating sheets into their own classes. (So you can have 'Dialogue', 'UIText' etc.) The implicit operator is temporary and will eventually reference my localisation manager.

    http://pastebin.com/JBSFXwhN

    You'll need to make a folder in Assets/: /0 - My Game/Scripts/Localisation/

    Place the script in an Editor folder anywhere (probably in the aforementioned Localisation directory), and ensure that G2U saves the object database to the default location. (It's deleted after this script is run.)

    Then just go to the top menu and run My Game -> Generate Localisation File.

    Side note: Is there a reason you are logging finding the editor assets folders? I'd love an option to turn this off, as I like to try and keep my console clear where possible, hehe.
     
    Last edited: Jun 15, 2016
  12. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    That particular log may be unnecessary now. You are safe to remove it.
     
  13. MrSterling

    MrSterling

    Joined:
    Feb 22, 2015
    Posts:
    1
    Shane,

    I'm having an issue with a null error message on any new Google2U action I create within Playmaker. I've tried creating new and copying older actions as well as whole states that have worked in the past and are actually still working. But the copied version is getting the null error and Playmaker is not completing the action. Oddly, when running the program I see that the variable are correctly being showing up (eg database name and row name), but the variable that holds the data value is showing up as zero.

    I did have a freeze in Unity that required a force quite about the time this problem started, so I'm not certain if that could have anything to do with it.

    Too, I have been making a number of changes within the Google database, but I've refreshed the database (pressed icon that looks like an old floppy) and validated that the row and column names align with what I'm calling within Playmaker.

    Any help you can provide would be helpful.

    Thanks
     
  14. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    MrSterling,
    Honestly this is a tough one. I can't really say for certain what could be happening here, but if you contact me directly we can try to sort through the problem. contact@litteratus.net is where you can reach me. Be sure to send whatever you are comfortable sending, and send me a link to your spreadsheet so I can try to reproduce the problem on my side.

    Shane
     
  15. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    223
    A couple of quick requests that would be nice if added;

    - Enum type. For static generation; if specified, it will grab the unique values from this column, and produce an enum containing the values. (similar to what's done in the ID column, albeit allowing multiple re-uses)
    - The ability to strip the _'s from prepended to property names in generated classes. I get they're there to avoid collisions with either internal properties, or c# keywords; but it'd be nice to have a checkbox and produce cleaner code.
     
    johanneskopf likes this.
  16. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    I'll see what I can do with the next release. Sounds relatively easy.
     
    johanneskopf and AFrisby like this.
  17. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hello,

    sorry, i've written a private message, reply didn't seem to work, but it's ok now :)

    I've read the manual, but i can't seem to find how to export to files TO spreadsheet so i can edit the values and import them back in unity.
     
  18. tyshock

    tyshock

    Joined:
    Jun 20, 2013
    Posts:
    6
    Is there any option for auto-refreshing the data as part of the normal build process? So far, I only identify the workflow of me manually refreshing each of my worksheets every time I want to load a data change. When fine tuning over several builds, this can get cumbersome.
     
    Johannski likes this.
  19. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    I actually came here for the same thing. I love the possibility to offer easy tweaking to my team through spreadsheets, but it can be quite frustrating to wait for the queries to finish. I'm not sure if a constant auto refresh is the best idea, because at some point the values in a table probably won't all be valid. I would love to see a scripting interface that I can use to automatically refresh the tables with the options I have first chosen in the gui window.

    That way I could for example connect that to a build prehook in order to be sure that the values are in sync with the most recent spreadsheet.

    Is there maybe a way to already do this, that I have missed? Sadly the documentation doesn't include that much information on how to access g2u functionality directly.

    €dit: Oh by the way, could you please change the name of the topic to the most recent version numer as well as changing the assetstore link back to forum.unity.com (It still is community.unity.com). I got kind of lost while searching for the right thread.
     
  20. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
  21. Discord

    Discord

    Joined:
    Mar 19, 2009
    Posts:
    1,008
    Is anyone aware whether it's possible to retrieve a rowId from row data?

    The constructor seems to take in an _ID but doesn't bother to store it anywhere. I'd rewrite the class, but it's being generated every time I update my spreadsheet.
     
    Last edited: Nov 23, 2016
  22. ELineCEng

    ELineCEng

    Joined:
    Sep 13, 2014
    Posts:
    8
    Hi @Shane-C ,

    First off, G2U is outstanding! My studio abandoned our own internal Google Sheets importer after we saw how much better G2U handled the task.

    In the past we typically used integer ids for our rows and exported the data as JSON. With G2U we encountered the requirement where ids must be strings. Am I correct in assuming this is to support exporting data as Object Database and/or Static Database? Is there a way to circumvent this requirement if we only intend to export the data as JSON?

    For now, I am working around this limitation by creating a column titled "dummy" of type "string" whose values are simply the relevant row cast to a string, then in G2U enabling the "Ignore ID Column", and finally using column B as our actual id column. Since the dummy values are numeric and ought to break the export process if they were used as variable names, I infer that these values are not actually relevant to this export case, yet are enforced all the same.

    Thanks,
    Chris

    G2uDummyIdColumn.PNG
     
  23. Sam-Kim

    Sam-Kim

    Joined:
    Oct 27, 2014
    Posts:
    6
    Thanks for great asset. lol
    When I export data as NGUI localization, g2u makes Localization.csv under folder named NGUI.
    but NGUI [UI Localize] script cannot recognize, because it's not under [Resources] folder
    I wonder why doesn't g2u makes Resources.
    (I also exported as StaticDB, at that time it makes files under StaticDB\Resources)

    I'm using NGUI 3.11.1, Unity 5.5.0f, latest version of g2u
     
    Duffer123 likes this.
  24. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    I've used this tool in several projects but in the latest one all a sudden every single import results in hanging Unity requiring a force quit in windows (all projects use 5.5.0f3). I have to wipe out my Google2uGen\StaticDB\Resources folder completely before every "save" I do from the editor window or else it hangs. Ever seen this before?

    Thanks.
     
  25. Xomanowar

    Xomanowar

    Joined:
    Apr 2, 2014
    Posts:
    40
    Hi, I'm trying to use Google2U on my game, but it will be a WebGL game, and G2U does not communicate with Google using this build target, is there any way to solve this?
     
  26. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @Shane-C , all,

    Is this Asset still supported and does anybody know if it works still with Unity 2017 and latest Google Drive?

    Also, presume if I want to reference resources like textures or other GOs or audio clips say I would use string columns with the resource path strings?
     
  27. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    @Duffer123 I do still support G2U through email, and there are no issues with 2017 that I've seen. GameObjects can be referenced by name, and if you use GameObject in the type row, code will be generated for finding the object in the scene and returning that instead of a string. Keep in mind this does use GameObject.Find, so don't abuse it
     
  28. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
  29. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    2.1.13 is available in the Asset Store
    Includes official Unity 2017 support (Fixed a deprecation warning), and the ability to export CSV, JSON, and XML files to a single subfolder rather than making a subfolder for each sheet. The option is in the Sheet Settings under Formatting Options.
     
    terrivellmann likes this.
  30. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    Hey all! We shipped in 2017 a game (Kona) using G2U and are now upgrading Unity to 2020 LTS. There seem to be an import / compilation issues with G2U DLLs, and we are using a really old version of it. Can anyone share me the latest package as it is deprecated from the store and Shane doesn't seem to respond to emails?
     
  31. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    I successfully downloaded the latest version via the package manager, but now am struggling to connect to my Google Drive. Google always block the connection, any idea how to resolve that? Manual published workbook also return an invalid message.
     
  32. terrivellmann

    terrivellmann

    Joined:
    Mar 10, 2015
    Posts:
    23
    It's not possible to sign in with Google anymore, but I was able to work with a manual published workbook up until now - not sure what changed but now I get an error saying the URL is invalid.

    @alexandre-fiset , did you manage to work around this?
     
  33. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    Unfortunately no. I tried to contact the author with no success. It really seems like G2U is just dead. In order to support more languages in my game I'll need to reverse engineer it or to rewrite our localization code. For now I just went on another task.
     
  34. terrivellmann

    terrivellmann

    Joined:
    Mar 10, 2015
    Posts:
    23
    Ah, shame. The fact that I could use the manual workbook method up until a while ago makes me think Google changed the generated URL structure when you publish to web and that broke the system.

    Definitely wish there was any way to contact @Shane-C still