Hi,
As the runtime conversion starts slowing down testing I'm looking into Articy:draft XML >> .asset conversion from the command line so that we can plug it into the build system. Can it be done with the current system?
Articy .asset conversion using a command line.
Re: Articy .asset conversion using a command line.
Hi,
What part of the workflow is slowing down testing?
Two ideas come to mind:
1. This idea can speed up the iteration time of testing changes made in articy: In your game build, allow the tester to specify an XML filename on the command line. In a Start() method in the first scene, use System.Environment.GetCommandLineArgs() to get the XML filename, and then convert it and add it to the Dialogue System's runtime environment using DialogueManager.AddDatabase(). Using this idea, the tester never has to open the Unity editor. Or, instead of the command line, you could build a UI into the game that lets the player select an XML file and import it while the game is running. Or, instead of a custom UI, you could write a C# method and register it as a Lua function. Then add a Lua Console so the player can call the function.
2. This idea can speed up the startup time of your build if your build converts the XML every time it starts: Instead of converting the XML every time the game loads, convert it once and save the dialogue database .asset file as an assetbundle. When your game starts, load the dialogue database from the assetbundle and add it using DialogueManager.AddDatabase(). If you make changes to your articy project, you can just replace the assetbundle without having to make a whole new build of the game.
You can also run Unity builds in "headless" mode (without display or input) by adding -batchmode to the command line arguments, but I don't know how this would be helpful in your case.
What part of the workflow is slowing down testing?
Two ideas come to mind:
1. This idea can speed up the iteration time of testing changes made in articy: In your game build, allow the tester to specify an XML filename on the command line. In a Start() method in the first scene, use System.Environment.GetCommandLineArgs() to get the XML filename, and then convert it and add it to the Dialogue System's runtime environment using DialogueManager.AddDatabase(). Using this idea, the tester never has to open the Unity editor. Or, instead of the command line, you could build a UI into the game that lets the player select an XML file and import it while the game is running. Or, instead of a custom UI, you could write a C# method and register it as a Lua function. Then add a Lua Console so the player can call the function.
2. This idea can speed up the startup time of your build if your build converts the XML every time it starts: Instead of converting the XML every time the game loads, convert it once and save the dialogue database .asset file as an assetbundle. When your game starts, load the dialogue database from the assetbundle and add it using DialogueManager.AddDatabase(). If you make changes to your articy project, you can just replace the assetbundle without having to make a whole new build of the game.
You can also run Unity builds in "headless" mode (without display or input) by adding -batchmode to the command line arguments, but I don't know how this would be helpful in your case.
Re: Articy .asset conversion using a command line.
We are currently importing XML automatically if it is newer. So idea 1 is the current situation and it has served us really well so far. Yet since the conversion takes 5 minutes each time people run it and it is un-cacheable I have wanted a more proper solution.
And since we started making assetbundles for graphics optimization I thought it was a good moment to have an assetbundle for the converted database so that the conversion is done only once, not for every writer/tester.
So I need to do the conversion in editor context and am asking if there is a nice API call for the exact same conversion that the UI converter does.
I want to make our server make the conversion only once for each XML iteration.
And since we started making assetbundles for graphics optimization I thought it was a good moment to have an assetbundle for the converted database so that the conversion is done only once, not for every writer/tester.
So I need to do the conversion in editor context and am asking if there is a nice API call for the exact same conversion that the UI converter does.
I want to make our server make the conversion only once for each XML iteration.
Re: Articy .asset conversion using a command line.
The articy converter editor window calls the same code as the runtime conversion methods. You can then save it as an asset and export it as an asset bundle. For example, you could write an editor menu item that does something like this:
If you haven't tried the articy converter in version 1.7.0, you might want to consider it. It runs much faster. However, it also adds support for nested conversations and other features that were added in articy 3.0, so carefully check the conversion results the first time you use it to make sure it still converts everything the way you expect. If you do try it, you may want to use the 1.7.1b1 version available on the Pixel Crushers website. It fixes a bug that caused the converter to convert all dialogues even if you had unticked some of the checkboxes in the converter window to specify that they shouldn't be converter. There are no other changes between 1.7.0's and 1.7.1b1's converter, so if you convert all dialogues you can stick with 1.7.0.
Code: Select all
// Create a dialogue database in memory:
var db = ArticyConverter.ConvertXmlDataToDatabase(xmlData, prefs, template);
// Save it as an asset file:
DialogueSystemMenuItems.CreateAsset(db, "My Database");
// Build the asset file into an assetbundle:
var buildMap = new AssetBundleBuild[1];
buildMap[0] = new AssetBundleBuild();
buildMap[0].assetBundleName = "My AssetBundle";
buildMap[0].assetNames = new string[] { "My Database" };
BuildPipeline.BuildAssetBundles("Assets/AssetBundles", buildMap, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
Re: Articy .asset conversion using a command line.
Thanks; I think I got it working.
A few remarks:
1) DialogueSystemMenuItems.CreateAsset(db, "My Database");
This function seems to be hidden in my normal usage scope; it was a good entry point and I could use it for my code. So nothing to change in that part.
2) If the portraits are not located direclty under "Resources", it fails to import the portraits.
This means that if I run the conversion from the "Articy Convert" dialogue, I get the actor images into the DB and if I run it from the ConvertXmlDataToDatabase() I do not get the portrait entries.
I suspect that it has to do with ArticyConverter.FindPortraitTextureInResources() function, which does not consider the prefs.portraitFolder and that the dialogue window conversion uses ArticyConverterWindow.FindPortraitTexture() .
Also: whee; 1.7.0 conversion time is down from several minutes to just 47 seconds. This is neat!
A few remarks:
1) DialogueSystemMenuItems.CreateAsset(db, "My Database");
This function seems to be hidden in my normal usage scope; it was a good entry point and I could use it for my code. So nothing to change in that part.
2) If the portraits are not located direclty under "Resources", it fails to import the portraits.
This means that if I run the conversion from the "Articy Convert" dialogue, I get the actor images into the DB and if I run it from the ConvertXmlDataToDatabase() I do not get the portrait entries.
I suspect that it has to do with ArticyConverter.FindPortraitTextureInResources() function, which does not consider the prefs.portraitFolder and that the dialogue window conversion uses ArticyConverterWindow.FindPortraitTexture() .
Also: whee; 1.7.0 conversion time is down from several minutes to just 47 seconds. This is neat!
Re: Articy .asset conversion using a command line.
I'm working on version 1.7.1. I'll check this.irve wrote:2) If the portraits are not located direclty under "Resources", it fails to import the portraits.
Great! Please double-check that it's actually converting everything exactly the way you want. Prior to 1.7.0, if you had a dialogue inside a flow fragment inside a dialogue, etc., it would only convert them as individual conversations without linking them. (Dialogues inside flow fragments could still be configured to use the flow fragment name as part of the converted conversation's name.) In 1.7.0+, the converter handles nesting.irve wrote:Also: whee; 1.7.0 conversion time is down from several minutes to just 47 seconds. This is neat!
Re: Articy .asset conversion using a command line.
The release candidate for version 1.7.1 has an editor function ArticyEditorTools.FindPortraitTexturesInAssetDatabase().
After converting your articy XML to a dialogue database in an editor script, you can now call ArticyEditorTools.FindPortraitTexturesInAssetDatabase() to search the portrait folder for images. You can only use ArticyEditorTools in an editor script, not at runtime. Example:
This is a separate function to because you can only search the project's Asset Database in the editor, not in a build, so it needs to be in the editor namespace.
After converting your articy XML to a dialogue database in an editor script, you can now call ArticyEditorTools.FindPortraitTexturesInAssetDatabase() to search the portrait folder for images. You can only use ArticyEditorTools in an editor script, not at runtime. Example:
Code: Select all
ArticyEditorTools.FindPortraitTexturesInAssetDatabase(database, prefs.PortraitFolder);