Automatic Articy import via editor script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
leonfor
Posts: 17
Joined: Tue Nov 30, 2021 6:31 am

Automatic Articy import via editor script

Post by leonfor »

Hey,

I've been looking for ways to ease the Articy/Dialogue System pipeline for our designers and one feature request that came up was triggering an automatic import of the Articy xml file in the Dialogue System upon exporting it (instead of bringing up the editor window and doing it manually).

Is there a way to accomplish this? I've successfully tracked down the xml file change with an asset post processor, but the only call I've seen in the docs to import it to the DS is

Code: Select all

ArticyConverter.ConvertXmlDataToDatabase(xmlFilename, converterPrefs, null);
which returns a DialogueDatabase that I'm not sure how to save in the project.

I've tried

Code: Select all

DialogueManager.AddDatabase(db);
but it doesn't update the database, even passing Overwrite = true in the prefs. (I assume this only works at runtime as specified in the import section of the docs)

Thank you.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Automatic Articy import via editor script

Post by Tony Li »

Hi,

The easiest way is to leverage the existing Articy import window. This is the code that the "Reconvert..." button uses in the upper right of the dialogue database inspector:

Code: Select all

bool alreadyOpen = Articy.ArticyConverterWindow.IsOpen;
if (!alreadyOpen) Articy.ArticyConverterWindow.Init();
Articy.ArticyConverterWindow.Instance.ReviewArticyProject();
Articy.ArticyConverterWindow.Instance.ConvertArticyProject();
if (!alreadyOpen) Articy.ArticyConverterWindow.Instance.Close();
When your asset importer detects a change to the XML file, you can run the same code.
leonfor
Posts: 17
Joined: Tue Nov 30, 2021 6:31 am

Re: Automatic Articy import via editor script

Post by leonfor »

Hey Tony,

quick and efficient as ever, thank you so much. For anyone wondering how to do this, just make sure to populate the relevant data in the importer window before triggering the two main functions:

Code: Select all

if(xmlFileChanged)
{
	bool alreadyOpen = ArticyConverterWindow.IsOpen;
	if (!alreadyOpen) ArticyConverterWindow.Init();
	ArticyConverterWindow.Instance.GetConverterPrefs().ProjectFilename = xmlFileName;
	ArticyConverterWindow.Instance.GetConverterPrefs().PortraitFolder = "path/to/portrait/folder";
	ArticyConverterWindow.Instance.GetConverterPrefs().OutputFolder = "path/to/output/folder";
	ArticyConverterWindow.Instance.GetConverterPrefs().Overwrite = true;
	ArticyConverterWindow.Instance.ReviewArticyProject();               
	ArticyConverterWindow.Instance.ConvertArticyProject();
	if (!alreadyOpen) ArticyConverterWindow.Instance.Close();
}
Note that the GetConverterPrefs() function doesn't exist in the articy converter window script, I added it since the prefs are a private member.

Anyways, I tested it and it works perfectly. Thank you again!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Automatic Articy import via editor script

Post by Tony Li »

Glad to help! Thanks for mentioning about setting up the importer window once first. I forgot to mention that.
Post Reply