Welcome, Guest
Username: Password: Remember me

TOPIC: Automating a google sheets import

Automating a google sheets import 11 months 4 weeks ago #2587


I'm using i2 localization with the google sheets sync and want to make it part of our nightly build process. The idea is to run the import from sheets->unity from a command line (and then check in the resulting changes) so it's always up to date. Yes, I know about the auto sync option but for various reasons that's not ideal.

However I can't see a way to do this from just a script. Is there an API call I can make to do a sheets->unity sync (with 'replace' preferably, but 'merge' would also be ok).

The administrator has disabled public write access.

Automating a google sheets import 11 months 4 weeks ago #2588

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 1139
  • Thank you received: 243
  • Karma: 72

The code that runs when you click the Import button is in:
function Import_Google at line 423

You could select the source and call that function, or alternatively, run the internal query by using:
        IEnumerator SyncSource()
            LocalizationManager.UpdateSources(); // ensures the source is loaded
            var source = LocalizationManager.Sources[0];
            var www = source.Import_Google_CreateWWWcall(true);
            yield return www;

            if (string.IsNullOrEmpty(www.error))
                source.Import_Google_Result(www.text, eSpreadsheetUpdateMode.Replace);

// call from your code using this:

Please, notice, that if you are executing that call from the Editor (not play mode), a normal coroutine will not work. But I2.Loc.CoroutineManager has code to simulate a coroutine by using the EditorApplication.update event.

That way, that code will work in both the editor and in-game.

Hope that helps,
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last Edit: 11 months 4 weeks ago by Frank.
The administrator has disabled public write access.
Time to create page: 0.249 seconds
Template by JoomlaShine