Automating a google sheets import
- OrangyTang
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
6 years 11 months ago #2587
by OrangyTang
Automating a google sheets import was created by OrangyTang
Hello!
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).
Thanks.
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).
Thanks.
Please Log in or Create an account to join the conversation.
6 years 11 months ago - 6 years 11 months ago #2588
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Automating a google sheets import
Hi,
The code that runs when you click the Import button is in:
assets\i2\localization\scripts\editor\localization\localizationeditor_spreadsheet_google.cs
function Import_Google at line 423
You could select the source and call that function, or alternatively, run the internal query by using:
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,
Frank
The code that runs when you click the Import button is in:
assets\i2\localization\scripts\editor\localization\localizationeditor_spreadsheet_google.cs
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:
I2.Loc.CoroutineManager.Start(SyncSource());
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,
Frank
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: 6 years 11 months ago by Frank.
Please Log in or Create an account to join the conversation.
Time to create page: 0.165 seconds