Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[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
    This is something that you'll have to write the logic for yourself. However it should be relatively straightforward.

    Pseudo:
    List< GoogleFu.myRowType > myRows = new List< GoogleFu.myRowType >();
    foreach( GoogleFu.MyRowType row in myDatabase.Rows )
    {
    if( row._MYCOLNAME == "someValue" )
    myRows.Add(row);
    }

    I wouldn't do it every frame, but you can certainly pull groups of values out of the spreadsheet using code very similar to this.
     
  2. kreischweide

    kreischweide

    Joined:
    Jan 2, 2013
    Posts:
    7
  3. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    The URL that GoogleFu needs is NOT the URL that is at the top of the browser window. When you go into the "Publish Workbook" dialog, the URL will be there. The URL that you posted is the HTML generated version of what your spreadsheet contains.

    In the Google doc, go to the File menu and click Publish to the Web.
    Click the Start Publishing button

    The URL will appear in the dialog box near the bottom. Copy and paste that one into GoogleFu.
    It will look something like this:
    https://docs.google.com/spreadsheet/pub?key=0AuAQSF2BjiuvdFasWdfc0x0bXg1S0FPdGNKZEEtekE&output=html

    Notice the string after "spreadsheet/pub?key=". It will be different than the one in your browser URL

    Hope that helps
    Shane
     
  4. kreischweide

    kreischweide

    Joined:
    Jan 2, 2013
    Posts:
    7
    Can't find it, maybe I'm blind, see https://dl.dropboxusercontent.com/u/3963769/unity/tmp/googlefu-publish.PNG
     
  5. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I have another request, can you build a bitmask from a column range?
     
  6. danien

    danien

    Joined:
    Jun 16, 2009
    Posts:
    71
    There is a conflict between GoogleFu and the Autopilot (Testflight) asset.

    Code (csharp):
    1.  
    2. Assets/AutoPilot/Editor/Scripts/TestFlightBuildWindow.cs(438,74): warning CS0436: The type `Google.GData.Client.HttpUtility' conflicts with the imported type `Google.GData.Client.HttpUtility'. Ignoring the imported type definition
    3.  
    Is there a way to avoid this? Thanks.
     
  7. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
  8. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Email me with the details of your request. This is a new one, and I'd like to see if it's better to write some custom code for this specific case, or implement it plugin-wide. Thanks!
     
  9. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Sounds like that other plugin also includes the Google.GData.Client.dll, removing (deleting) one or the other should solve the warning.
     
  10. danien

    danien

    Joined:
    Jun 16, 2009
    Posts:
    71
    Unfortunately, I think it uses a different version of the DLL as I get this error if I delete it (for GoogleFu; can't find it for Autopilot).

    Code (csharp):
    1.  
    2. Internal compiler error. See the console log for more information. output was:
    3. Unhandled Exception: Mono.CSharp.InternalErrorException: Assets/GoogleFu/Editor/GoogleFu.cs(12,30): GoogleFu.GoogleFuEditor ---> Mono.CSharp.InternalErrorException: Assets/GoogleFu/Editor/GoogleFu.cs(19,71): GoogleFu.GoogleFuEditor._service ---> System.IO.FileNotFoundException: Could not load file or assembly 'Google.GData.Client, Version=2.1.0.0, Culture=neutral, PublicKeyToken=04a59ca9b0273830' or one of its dependencies.
    4. File name: 'Google.GData.Client, Version=2.1.0.0, Culture=neutral, PublicKeyToken=04a59ca9b0273830'
    5.   at (wrapper managed-to-native) System.Reflection.Assembly:InternalGetType (System.Reflection.Module,string,bool,bool)
    6.   at System.Reflection.Assembly.GetType (System.String name, Boolean throwOnError, Boolean
    7.  
    I'll try asking the Autopilot's author. Thanks.

    EDIT: http://forum.unity3d.com/threads/10...-the-asset-store/page19?p=1643030#post1643030
     
    Last edited: May 28, 2014
  11. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    That's odd. So, if you were to ignore the warning, do both plugins operate as expected? I think I had to recompile the GDATA libs in order to get them to work with Mono, but I didn't change any code. Since you can't find the DLL's for their plugin I wonder if they just compiled the relevant code directly into their project?
     
  12. RobRab2000

    RobRab2000

    Joined:
    Nov 28, 2012
    Posts:
    19
    Hi,

    This plugin is great!

    It took me a while to get it all set up but It's just Awesome!

    So I was wondering if it's possible to get it to work at runtime? :)

    I know in an earlier post you mentioned that this is an editor extension only but I was just wondering if it was an upcoming feature? It would just be nice to run beta testing and be able to modify balancing without having to push new builds every time I change the speed at which the Ogre walks by half a percent..

    Also I'm having the same issue as kreischweide. Trouble getting the public link to work.. Do you think perhaps google have changed their link format because I can't see anything about a 'pub?key=' in the url they provide?

    Last thing, could I suggest perhaps adding into the documentation a section on how to pull specific data from the columns, not just how to get the rows.. it took me ages to eventually figure it out :( (it might just me being an idiot but considering how the rest of the documentation is so thorough and step-by-step i felt a little lost.. like it had just stopped half way through.. sorry
     
  13. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Awesome!

    What do you feel could be done differently to streamline the process, if anything?

    The most frequently asked feature request. We are certainly looking into it. We have a prototype that will allow you to save modified settings and push them back to Google. It's still not at runtime, but it's close enough. The part that is missing is data validation. ie. If the spreadsheet is modified at any time between pulling from Google and Pushing back, there is no way to reconcile the changes, thus leaving you with a bad spreadsheet, and no way of rolling back. We feel that it would cause more problems in the long run, and believe me, you don't want to see my inbox of support issues..


    I am looking into this. It's not happening to me, and I can't seem to get a repro case going to troubleshoot the issue. I know Google sometimes rolls out changes to targeted users first, perhaps I'm not one of them. Meanwhile, in the GoogleFu code there is a line that parses the URL for the public documents, looking for the "key". I suspect the URL has changed slightly, and my parsing method is no longer working. If you were to poke around with that, perhaps you will get it working before I am able to. Meanwhile, private documents should still work, provided that you have the login information to the Google account that owns the spreadsheet.

    I'll take another look at it. Nobody has mentioned that specific shortcoming with the documentation, it could be that I have simply overlooked a step.

    Thanks for using GoogleFu!
    Shane
     
  14. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Sent a week ago, no reply, have you read it?
     
  15. RobRab2000

    RobRab2000

    Joined:
    Nov 28, 2012
    Posts:
    19
    Hi Shane,

    Thanks so much for getting back to me. Your plugin has made me totally rethink the way I'm gonna be dealing with balancing and designing my game! It's so exciting!!

    So I am a bit of a retard cos I didn't actually see the info on page 24 of the documentation.. this is exactly where you explain how to access the data from the columns.

    So I think the reason for the confusion (other than me just simply not reading the documentation thoroughly enough) is that on pages 21 & 22 you explain about how to access the column data for a game object (which is how I am using it). I then expected that it would explain how to access the columns. When I saw it start reading about static databases I kinda tuned out.. Maybe you could consider explaining about accessing columns for each section (u know, for other retards who can't figure out how to scroll an extra page or two to find the answer).

    :)

    So for the runtime aspect, I personally don't need to write to the spreadsheet from the game. Only reading. Read only needs to happen at the game's start up.. or at the beginning of a level. possibly even have a way to remotely trigger the spreadsheet load?

    I'm just thinking it would be cool to be able to test different configurations of enemy properties without having to compile new builds.

    Lastly, I can send you the link to the spreadsheet so you can have a look at how its written and use for test purposes if you'd like? I'd prefer not to post it in a public message but I could email it to you privately if you could leave me your email address?

    Thanks again :)
     
  16. RobRab2000

    RobRab2000

    Joined:
    Nov 28, 2012
    Posts:
    19
    Also, I was wondering if there was a way to count how many columns are in a row?
     
  17. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Actually, no.. not really. Once you have access to the Row class all columns are directly accessible, and the variable names are whatever you named them in the spreadsheet. But other than dumping the row to the console via the ToString() override, there is no real way to get a count. This is something that is extremely easy to add, and I'll put it on the list for the next release.

    I have two major issues with accessing Google at runtime, and they are related somewhat.
    1. The Google DLL's will have to be linked into the runtime, rather than just the editor. This creates issues for mobile/web targets. Mobile targets can't link them unless they are using the Pro version of Unity. And Web can't link them at all.. period. So making that change would alienate users. Web and Mobile users already have to switch targets to even use GoogleFu.. this would be even more of a burden for them.

    2. Even if this were not an issue, Runtime access to public and private databases would require scripts to hardcode credentials into the game. This is a huge security risk, as Unity games are fairly easy to reverse engineer. Even if you never intend on scripts staying in, and only want to do this during the development phase, accidents happen. Once somebody gets ahold of your Google username and password.. well.. I'd prefer GoogleFu not be what opened the can of worms

    I'm not saying it's impossible, because I've done it. In initial implementations I did have it working, but I couldn't get past the security issues associated with it, and decided to go a different direction.



    As for me looking over your spreadsheet, send a link to contact@litteratus.net and I'll be happy to
     
  18. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Sorry imtrobin, somehow it was buried into another email chain. Gmail must have decided that "all emails with the subject line GoogleFu go here".

    I've replied now.
     
  19. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    I'm still looking into this.. and still can't repro.

    Let me verify that you are doing everything that needs to be done.

    1. In the Google Spreadsheet, click File -> Share.. (The very first option in the file menu)
    2. In the Share dialog under "Who has access" click the "Change.." link. The Sharing Settings dialog will appear
    3. In the Sharing Settings dialog Tick "Public on the Web"
    4. In the Sharing Settings dialog change the access to "Can View" (Or if you are a donkey on the edge, "Can Edit")
    5. In the Sharing Settings dialog Click the Save button
    6. In the Sharing Settings dialog, Click the Done button

    At this point you will be back at your Spreadhseet, we will go into 1 more panel to get the URL
    7. In the Google Spreadsheet, click File->Publish to the Web
    8. In the Publish to the Web dialog, in the first section choose "All Sheets"
    9. Click the "Start Publishing" button
    10. In the second section (Get a link to the published data) choose "Web Page" and "All Sheets"
    11. In the last box, a URL should be there that has

    https://docs.google.com/spreadsheet/pub?key={some long key}&output=html

    If anything fails along the steps, please let me know where/what went wrong.

    Thanks
    Shane
     
  20. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    OK, so for sheets created after a certain date, this has changed.
    A quick test with a change that pulls the key out of this URL also failed.

    I'm going to have to look into why this is happening and see if there is an alternate way of getting the correct key now. I'll keep you updated here.
     
  21. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Alright everyone, the steps for generating the Manual URL remain largely the same, only the final URL in the Published Document will look different than the documentation states. This ONLY happens for documents created AFTER a certain date (Not sure exactly when that date is, but I didn't look all that hard either.)

    The new URL format causes issues with the way GoogleFu parses and retrieves the Key.

    To temporarily fix this issue, open the GoogleFu.cs in Monodevelop and search for the following function:

    WorkBookInfo AddManualWorkbookByURL (string manualURL)

    replace the entire function with the following code:

    (Click to expand the quote)

    This will try the old method first, and if it fails (which it will if the URL is not exactly right) then it attempts the new method of grabbing the spreadsheet.

    Just to recap.

    Old style URL: https://docs.google.com/spreadsheet/pub?key={some long key}&output=html
    New style URL: https://docs.google.com/spreadsheets/d/{some long key}/pubhtml

    There are still a few features left to finish up and test before I release the next version of GoogleFu to the store, in the meantime this code will get all of you Manual URL users up and running.

    Sorry it took so long to figure this one out.

    Shane
     
  22. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Version 1.0.10 has been submitted. It's a big one...

    Generated Code:
    • Added a property for the number of columns in a Row ( Row.Length )
    • Added the ability to get the string value of a Row using the bracket operators

    Arrays:
    • Added support for data arrays in individual cells

    GUI:
    • Added the ability to choose delimiters for single cell arrays
    • Added an option to trim whitespace on strings
    • Added an option to trim whitespace on string arrays

    Export:
    • Added the option for CSV export directly

    Compatibility:
    • Restricted GoogleFu from operating under invalid build targets
    • Updated Manual Workbook support to work with the new URL generated when you publish to the web
    • Removed support for char, short and double value types

    Bug Fixes:
    • When generating an object database, if an error is detected the generation will stop immediately and report an error
    • Quaternions are now displaying correctly in the Editor
    • Improved some error conditions and debug output


    Look for the updated version in the Asset Store soon. I'll update the first post when it's been accepted.
     
  23. RobRab2000

    RobRab2000

    Joined:
    Nov 28, 2012
    Posts:
    19
    That's wonderful news! Well done Shane :)
     
  24. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    GoogleFu 1.0.10 is live!
    Go get it!
     
  25. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Great to see update.
    I have a question. How do you delete or reset worksheets in active workbook?
    I've changed sheet names and the old ones seem to stay there.


    [Edit] Ahh never mind, sorry hitting the play button fixed the problem
     
    Last edited: Jun 15, 2014
  26. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    So, I will be pushing a fix for a small issue that was overlooked.
    Until then, if you have an array with no entries, GoogleFu will not be able to compile the object database. (Yeah I know, it must be amateur hour over here at Litteratus.. how could we have missed that test case??)

    To hotfix until the new version is posted:

    On (or around) line 4081 in GoogleFu.cs you will see the line:
    Code (csharp):
    1. if(types[i].ToUpper().Contains("ARRAY"))
    You will need to replace that line, all the way until the comment:
    Code (csharp):
    1. // when you switch the row you are examining, they may have different array sizes... therefore, we may actually be past the end of the list
    With the following code:
    Code (csharp):
    1.  
    2. if(types[i].ToUpper().Contains("ARRAY"))
    3. {
    4.     fileString += formatLine("            if ( r." + varNames[i] + ".Count == 0 )");
    5.     fileString += formatLine("            {");
    6.     fileString += formatLine("               GUILayout.Label( \"" + colNames[i] + "\", GUILayout.Width( 150.0f ) );");
    7.     fileString += formatLine("               {");
    8.     fileString += formatLine("                  EditorGUILayout.LabelField( \"Empty Array\" );");
    9.     fileString += formatLine("               }");
    10.     fileString += formatLine("            }");
    11.     fileString += formatLine("            else");
    12.     fileString += formatLine("            {");
    13.     fileString += formatLine("               GUILayout.Label( \"" + colNames[i] + "\", GUILayout.Width( 130.0f ) );");
    14.      // when you switch the row you are examining, they may have different array sizes... therefore, we may actually be past the end of the list
    All this is doing is inserting an IF check into the editor script to ensure the List is not accessed if it doesn't contain any entries. This should get you up and running.

    Remember, if you do have an array, once you access the value, it is up to you to bounds check it! It's stored as a List<T> so just use .count to ensure you don't access a non-existent index :)
     
  27. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Version 1.0.11 has been submitted with this fix.
     
  28. 5on26black

    5on26black

    Joined:
    May 25, 2013
    Posts:
    1
    Just updated to 1.0.10 and GoogleFu window states that the build target is now invalid...was having no problems in 1.0.9b. Looking at the release notes I noticed "Restricted GoogleFu from operating under invalid build targets" was added with the update. Do you have a list of restricted build targets that changed from 1.0.9b? What was the reason for this restriction?
     
  29. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Well, first off let me apologize, the code I implemented was unintentionally aggressive. It shouldn't have locked out the free version of the Android and iOS build targets. It was intended to lock out the Web Player target and other incompatible (xbox 360, ps3, ps4, etc) targets. Unfortunately this was another one that fell through the cracks.

    The good news is:
    This will be fixed with the 1.0.11 version, already pending review.
    and
    It's super easy to get around until then. Just look for the OnGUI function in GoogleFu.cs and comment out the entire first if/else block. This will circumvent the check entirely.

    If you are using the free version of GoogleFu and need a fixed copy before 1.0.11 is approved (I am hoping in the next day or so), email me at support@litteratus.net and I'll send you the fixed version.

    Again, sorry about that... It was one of the first features I implemented in 1.0.10 and didn't test it thoroughly.

    Shane
     
  30. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    1.0.11 is live.

    Fixed the lockout issue with Android and iOS build targets
    Fixed the zero length array issue

    Barring any major issues, the next feature slated will be the ability to mark columns as "Ignore", so GoogleFu will not try to import them. This will be immensely helpful for columns that contain notes, formulas, or anything else that doesn't need to be in your game.

    Shane
     
  31. alvinphu

    alvinphu

    Joined:
    May 24, 2013
    Posts:
    2
    It seems your CSV exporting feature is broken, it was missing a line?

    Before:
    if ( ( _useObjDB && useExportObjDB ) ||
    ( _useStaticDB && useExportStaticDB ) ||
    ( _useNGUI && useExportNGUI ) ||
    ( _useJSON && useExportJSON ) ||
    ( _useXML && useExportXML ) ||
    ( _useDaikonForge && useExportDaikonForge ) )
    activeEntries.Add( entry );

    After:
    if ( ( _useObjDB && useExportObjDB ) ||
    ( _useStaticDB && useExportStaticDB ) ||
    ( _useNGUI && useExportNGUI ) ||
    ( _useJSON && useExportJSON ) ||
    ( _useXML && useExportXML ) ||
    ( _useCSV && useExportCSV ) ||
    ( _useDaikonForge && useExportDaikonForge ) )
    activeEntries.Add( entry );

    Also could you add in an option to not use quotes as a text delimiter for CSVs?
     
  32. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Yes, I am pretty sure the missing line was due to a hasty merge error. It'll be fixed ASAP.
    And yes, the default implementation for CSV's would surround strings with quotes. I'll remove that from CSV export.

    Thanks!
    Shane
     
    Last edited: Jun 27, 2014
  33. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    95
    Quick question - how is JSON parsing handled? Is it up to us to implement our own parser for the resulting JSON file? The public docs aren't clear about this, just curious how it is handled.

    Thanx
     
  34. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    GoogleFu doesn't handle parsing the resulting JSON file. It will be up to you to implement whatever method of parsing you choose. Version 12, which will be coming out very soon, changes the resulting JSON file a bit, but if you start on your own parser it shouldn't take any time at all to adapt.

    Shane
     
  35. gekidoslair

    gekidoslair

    Joined:
    Sep 7, 2012
    Posts:
    95
    Sounds great. JSON is super easy to use, so writing a custom parser isn't a problem, just curious ;}

    Thanx!
     
  36. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Version 12 has been submitted to the asset store.

    1.0.12
    Added feature to ignore marked columns and rows
    Fixed missing strings in the editor
    Fixed a bug with submitting non-excel documents when uploading to Google
    Improved auto-generation of output directories
    Fixed a bug with CSV exporting
    Added an option to surround strings with quotes in CSV export. Off by default.
    Removed dependency on Newtonsoft.Json.dll to improve compatibility with other plugins

    When you get this update you are free to delete the Newtonsoft.Json.dll in your GoogleFu editor directory.
    I'll update the release notes post when GoogleFu is approved.
     
  37. Hoskins355

    Hoskins355

    Joined:
    Jan 3, 2013
    Posts:
    142
    Can you add support for Texture2D? Other database solutions allow Texture2D. I really like your asset and if it supports Texture2D I will buy the pro version.
     
  38. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    The Google API doesn't support getting Image data from the spreadsheet. I looked into this when I was giving you Email support on Monday. The Cells in Google that contain only image data are entirely blank when GoogleFu reads them, so supporting them that way is impossible (Until Google supports it, then I'll gladly add the functionality).

    The best alternative for you right now is to reference the image name in the Google Spreadsheet, and load them in at runtime via that name.

    I am curious, What other database solutions support reading and creating Texture2D? I will certainly look into them.
     
  39. Hoskins355

    Hoskins355

    Joined:
    Jan 3, 2013
    Posts:
    142
    I was looking at
    https://www.assetstore.unity3d.com/en/#!/content/893
    https://www.assetstore.unity3d.com/en/#!/content/5454

    Both support images I would be willing to use image name instead if that could be easily implemented. I can even save images into the Resources folder if that would be easier. Please let me know I love your product but I really need a way import pictures, otherwise I have to code in each picture for each question manually, which I can do but if I am going to code everything manually then there really is no need for a automated solution. Please let me know if we can get images to work I would gladly buy your product and give you a good review.

    Thanks
    Brandon
     
  40. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Ah, yes both of those are dedicated database solutions. GoogleFu is designed to read spreadsheets. GoogleFu does not use a typical database, but rather leverages a generated class, and uses Game Objects to store/retrieve data. Unfortunately we are at the mercy of Google's API to access data. (There is another plugin similar to GoogleFu on the Asset Store now that uses WWW calls, But I believe it will be just as crippled as us when it comes to reading actual images.. I don't know though so you should probably check it out).

    Here's what I would do in your case.
    Option A: Leverage the Resources directory. Dump all of your images into a Resources directory, and put the names of the images into your Google Spreadsheet (Without the extension, you won't need it). Use the following code to access the images from your resources directory:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using GoogleFu;
    4.  
    5. public class Test : MonoBehaviour
    6. {
    7.     Sheet1 _MyDb;
    8.     Sheet1Row _MyRow;
    9.     Texture2D _MyImage;
    10.  
    11.     Rect _MyQuestionRect;
    12.     Rect _MyImageRect;
    13.     Rect _MyAnswerRect_A;
    14.     Rect _MyAnswerRect_B;
    15.     Rect _MyAnswerRect_C;
    16.     Rect _MyAnswerRect_D;
    17.  
    18.     void Start ()
    19.     {
    20.         GameObject dbobj = GameObject.Find("databaseObj");
    21.         if (dbobj != null)
    22.         {
    23.             _MyDb = dbobj.GetComponent<Sheet1>();
    24.  
    25.             _MyRow = _MyDb.Rows[ (int)Sheet1.rowIds.Q01 ];
    26.             _MyImage = (Texture2D)Resources.Load( myRow._IMAGE);
    27.             _MyQuestionRect = new Rect( 10, 10, 500, 40 );
    28.             _MyImageRect = new Rect( 10, 50, 100, 100 );
    29.             _MyAnswerRect_A = new Rect( 10, 160, 500, 40 );
    30.             _MyAnswerRect_B = new Rect( 10, 210, 500, 40 );
    31.             _MyAnswerRect_C = new Rect( 10, 260, 500, 40 );
    32.             _MyAnswerRect_D = new Rect( 10, 310, 500, 40 );
    33.         }
    34.     }
    35.  
    36.     void OnGUI ()
    37.     {
    38.         GUI.Label(_MyQuestionRect, "Question:" + myRow._QUESTION);
    39.         if( _MyImage != null )
    40.             GUI.DrawTexture(_MyImageRect, _MyImage);
    41.         GUI.Label(_MyAnswerRect_A, "A:" + myRow._A);
    42.         GUI.Label(_MyAnswerRect_B, "B:" + myRow._B);
    43.         GUI.Label(_MyAnswerRect_C, "C:" + myRow._C);
    44.         GUI.Label(_MyAnswerRect_D, "D:" + myRow._D);
    45.     }
    46. }
    (In case anyone is wondering, the OP and I have had a previous conversation via Email, which is why this script is so involved and specific)

    As long as you have an image in your Resources that matches the name in the Images column, it should load and display your image. Of course you will need to get a lot more involved later on, but this should get you started. You can see the relevant lines are:
    Code (csharp):
    1. _MyImage = (Texture2D)Resources.Load( myRow._IMAGE);
    and
    Code (csharp):
    1. if( _MyImage != null )
    2.        GUI.DrawTexture(_MyImageRect, _MyImage);
    Option B: If you have Unity PRO, you can leverage Asset Bundles to achieve the same thing. Again this will take some preparation on your end, and is not fully automated by GoogleFu

    Option C: Use one of the other database solutions that you discovered on the Asset Store. GoogleFu is not a one-stop solution for everything, and I won't pretend it is. If you find another solution that works better in your case, believe me you will be much happier in the long run rather than trying to shoehorn a solution in that isn't quite right!
     
  41. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    1.0.12 is live!

    We are considering changing the name of the asset.
    What do you think?
    Good idea? Bad idea? Indifferent?

    If you were to rename GoogleFu, what would you name it?
     
  42. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Reporting problems with json export 1.0.12

    1. Header row, string item A1, is exported wrongly

    MYTest
    Data

    ie exported in json as
    Code (csharp):
    1.  
    2. "Data:Data" instead of "MYTest:Data"
    3.  
    2. Can we get option to ignore the spreadsheet bracketing

    3. The header rows are changed to lowercase . I want to preserve
     
  43. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Looks like a couple easy fixes. I'll get on it.
     
  44. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    GoogleFu is going to be on sale for the next 48 hours!

    50% off!
     
  45. ghost012

    ghost012

    Joined:
    Jan 3, 2013
    Posts:
    13
    I'm getting a couple of errors.

    4 related to VOID and Playmaker actions

    (i have 2 voids in my sheet)
    2x
    Assets/GoogleFu/Custom Actions/GoogleFu/GetUnitstatsbase1DataByID.cs(25,30): error CS1519: Unexpected symbol `;' in class, struct, or interface member declaration

    2x
    Assets/GoogleFu/Custom Actions/GoogleFu/GetUnitstatsbase1DataByIndex.cs(28,30): error CS1519: Unexpected symbol `;' in class, struct, or interface member declaration

    These 2 are giving the error.


    [Tooltip("Store the _VOID in a Ignore variable.")]
    public _VOID;

    [Tooltip("Store the _VOID_2 in a Ignore variable.")]
    public _VOID_2;
     
  46. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    ghost012, please email me at contact@litteratus.net and we'll work through this.
    There were a couple of changes to the Playmaker related code recently, and while we tested them, I am not completely convinced the code is bug free. We'll get this fixed for you.
     
  47. -JohnMore-

    -JohnMore-

    Joined:
    Jun 16, 2013
    Posts:
    64
    Hi,

    I am using GoogleFu for a lot of things and it's working great, but I am having some problems and was hoping you could give me some hints on what is happening.

    1. Localization files not exporting correctly. One of the things I am doing with GoogleFu is localization, but when I export the workbook, some cells (sometimes just a few cells, sometimes full columns) do not export correctly. For example, take this MainMenu workbook and the generated GameObject:

    Screen 140917 WorkbookData.jpg

    Screen 140917 GameobjectData.jpg

    The last 2 columns are calculated. Sometimes the chinese column would be correctly exported, sometimes the japanese one, sometimes neither of them. I was thinking this could be a timeout when downloading the workbook before exporting it or something like that, and was hoping for some fix.

    The other way is using the translate option, then removing the formula while keeping the translated text. It not that bad but it is time consuming and I have a lot of text.


    2. The second problem is that GoogleFu logs off all the time. I think it logs off every time the project is compiled. Can the login token be cached for a while? Even 5 minutes would be a great gain for me. I am constantly working with GoogleFu since my game configuration and balancing is stored in your GameobjectDB type, but everytime I change some data or texts and export the object again, it triggers a project recompilation and GoogleFu logs off.


    Other than that, I am really happy with the quality and functionality of this plugins. Thanks a lot.

    Cheers!
     
  48. Shane-C

    Shane-C

    Joined:
    Nov 9, 2012
    Posts:
    211
    Hey there John. (My best friend growing up is named John Moore.. Crazy.. anyhow)

    I believe the issue with #1 is on Google's end. I have the exact same problem when I have to change/add strings. Google will sometimes time-out when it's calculating translations using the formula. I've looked, and unfortunately there is no way on our end to force Google to process cells. If you open the worksheet you'll probably notice that some cells have a #N/A value. That means Google timed out on their end, and you have to force it to recalculate. When that happens, I put a space at the end of the text, and manually force it to recalculate. Unfortunately if you revert immediately afterwards it will have the #N/A value cached. I haven't yet found a workaround. I toyed with keeping two separate columns, one for auto-translation and one for the result with an if check to filter out #N/A values. If you mark the translation formula columns as VOID, it should skip them. This is all theory but I'll be giving it another try soon. In the meantime, the best you can do is manually force them to translate, and once the entire sheet is done, don't re-export the translations until you absolutely have to.

    As for #2, this is top priority for us right now. You're right, we are invalidating the token too often. The problem has been that we don't have any control over how long the token stays valid for on Google's side, and if we keep it hanging around too long, things just stop working. There are ways we can possibly keep the token around for longer periods of time, and we are testing ideas now. In the meantime, just save the password and auto-login. This is all done locally on your machine (And unfortunately unencrypted, so make sure you uncheck them before you shut down to clear the values if you have privacy concerns). Just know that we are looking into it. We know it's a problem and next to runtime access of Google (Which isn't going to happen anytime soon) it's the most requested improvement.

    If you have anymore questions or concerns, feel free to email me. support@litteratus.net

    Shane
     
  49. -JohnMore-

    -JohnMore-

    Joined:
    Jun 16, 2013
    Posts:
    64
    Hi!, Fast response, thank!

    About issue #1, it's weird because in my case, all the cells are correctly translated in the google spreadsheet, the last #VALUE! column is a template column so it's ok. But the moment I export the workbook in Unity most fields get the "Loading..." value. I have fixed it by copying the translated values and overwriting the formulas so the data now sticks and exports great. I think it is a google-translate issue because I have lots of workbooks with many formulas for game balancing and they have been working without problems from the start. I think google is re-evaluating the formulas when you export them and then they timeout.

    About issue #2, I am currently queueing GoogleFu tasks until I have a few updates to do, then I export all the workbooks at the same time. I have tried to Save password and autologin but the experience was not good: it kept login off and then Unity freezed for half a minute until auto-login finishes so I disabled it and started batching GoogleFu tasks.

    Just an idea that maybe you can find interesting. In my case, I have a bunch of translations workbooks: SaveSlot, MainMenu, OptionsMenu, CampaignMenu, and so on, each one with a list of texts and their translations. Many times I use them from code, but most of the time is just static labels so I needed a generic way of accessing the data in your DB objects. Currently, each DB has a custom name from the workbook, and the same happens with the datarow, so I updated the GoogleFu.cs script to use 2 interfaces I made. Now every db and every row can be accesed from my translation labels. Just an idea...

    Code (CSharp):
    1. namespace GoogleFu
    2. {
    3.     public interface IGoogleFuRow
    4.     {
    5.         string GetStringData( string colID );
    6.     }
    7.  
    8.     public interface IGoogleFuDB
    9.     {
    10.         IGoogleFuRow GetGenRow(string rowString);
    11.     }
    12. }
    The GetGenRow method is your GetRow method, but using the row interface as the return value type. Now my label can access any database and look for any string and I just have to configure 1 variable (LangManager.Lang) to change language in my game:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using GoogleFu;
    4.  
    5. public class TextTranslator : MonoBehaviour
    6. {
    7.     #region STATIC
    8.     public static string GetGenText(IGoogleFuRow genRow)
    9.     {
    10.         return genRow.GetStringData(LangManager.Lang);
    11.     }
    12.     #endregion
    13.  
    14.     #region CONFIGURATION
    15.     public GameObject TranslationObject;
    16.     public string TranslationKey ="";
    17.     #endregion
    18.  
    19.     #region STATUS
    20.     Text textLabel;
    21.     IGoogleFuDB translationDB;
    22.     #endregion
    23.  
    24.     #region UNITY
    25.     void Start()
    26.     {
    27.         translationDB = TranslationObject.GetComponent<MonoBehaviour>() as IGoogleFuDB;
    28.         textLabel = GetComponent<Text>();
    29.         translate();
    30.     }
    31.     #endregion
    32.  
    33.     #region TASKS
    34.     void translate()
    35.     {
    36.         if(textLabel != null && !string.IsNullOrEmpty(TranslationKey) && translationDB != null){
    37.             textLabel.text = GetGenText(translationDB.GetGenRow(TranslationKey));
    38.         }
    39.     }
    40.     #endregion
    41. }
    Thank you!
     
  50. Symyon

    Symyon

    Joined:
    Nov 26, 2012
    Posts:
    30
    Hi, I have a problem when exporting data from google docs. All my column names that have an underscore are exported without it. So for instance: "column_name" will be exported as "columnname". Is there a way to fix this?
     
unityunity