Page 1 of 2
Articy import in C#
Posted: Fri Jan 15, 2016 10:08 am
by irve
I'm trying to shorten the feedback loop for the writers. Would it be possible to somehow call PixelCrushers.DialogueSystem.Articy.ArticyConverter from withing the game?
What we'd like to do is to add a button "Update Database" which would load the XML resource and replace the currently running database. I'm currently stuck in even more stupid place:
Code: Select all
using PixelCrushers.DialogueSystem.Articy;
This code complains about not finding Articy part of the namespace. So I started thinking if I'm way off the tracks here...
Re: Articy import in C#
Posted: Fri Jan 15, 2016 11:12 am
by Tony Li
Hi,
PixelCrushers.DialogueSystem.Articy is an editor-only namespace. It's currently not available to runtime scripts.
If your writers are working in the Unity editor, they can run the converter and use
DialogueManager.AddDatabase() to load the newly-converted database into the runtime environment. You could provide a button that calls RemoveDatabase() to remove the old version and then AddDatabase() to add the new version.
For the next release, I'll look into making the converter available to runtime scripts so you can import XML in builds. This might also be useful for player mods.
Re: Articy import in C#
Posted: Fri Jan 15, 2016 9:06 pm
by Tony Li
Here's an example scene that demonstrates reloading a database at runtime:
ArticyImportEditorRuntime_2016-01-15.unitypackage
Currently a database named "Feature Demo" is assigned to the Runtime Database Manager. Assign your articy:draft database instead.
If you're in the Unity Editor, while playing you can re-run the articy Converter and click the Refresh Database button to see the changes reflected in the scene.
In the next version, ArticyConverter (or an equivalent class name) will be available to your runtime scripts.
Re: Articy import in C#
Posted: Sat Jan 16, 2016 2:00 am
by irve
Thank you! We were thinking of not teaching the writers how to mess with Unity and thus the "modding pathway" was looked into.
I also have to compliment you on Dialogue System support, since this is the first question in months that I didn't find an answer for.
Re: Articy import in C#
Posted: Sat Jan 16, 2016 8:12 am
by Tony Li
Thanks! I'm glad the Dialogue System is working out for you!
The next version should be out at the end of January. I'll make sure it has runtime modding support for articy:draft XML files.
Re: Articy import in C#
Posted: Tue Feb 09, 2016 10:41 am
by irve
When I get the new database from the converter; how can I swap out the existing one?
Should I iterate over controllers/triggers to swap out the reference or is it somewhat more straightforward?
Re: Articy import in C#
Posted: Tue Feb 09, 2016 11:23 am
by Tony Li
irve wrote:When I get the new database from the converter; how can I swap out the existing one?
Should I iterate over controllers/triggers to swap out the reference or is it somewhat more straightforward?
Call
DialogueManager.RemoveDatabase() to remove the old database. Then call
DialogueManager.AddDatabase() to add the new one. Note that this will reset any data in the Lua environment that's associated with the old database.
Example:
Code: Select all
DialogueManager.RemoveDatabase(DialogueManager.Instance.initialDatabase);
var database = ArticyConverter.ConvertXmlToDatabase(myXmlData);
DialogueManager.AddDatabase(database);
You don't need to do anything with triggers. Internally, they use strings to reference conversation titles and quest titles. They don't actually have direct references to any databases.
Re: Articy import in C#
Posted: Thu Feb 11, 2016 8:38 am
by irve
I think that I found the issue; for those who might struggle here (by looking at "info" level logs):
Initial database:
Code: Select all
Dialogue System: Lua(Conversation[92] = { Status = "", Title = "Conventions / Test without semantics", Pictures = "[]", Description = "Testing dialogue devoid of emotions", Actor = 47, Conversant = 50, Articy_Id = "0x010000110000030B", Dialog = {}})
New, imported one:
Code: Select all
Dialogue System: Lua(Conversation[92] = { Status = "", Title = "Conventions/Conventions / Test without semantics", Articy_Id = "0x010000110000030B", Description = "Testing dialogue devoid of emotions", Actor = 59, Conversant = 62, Dialog = {}})
So: starting the conversation, which is named "Conventions / Test without semantics" will certainly fail, since the ConvertXmlToDatabase() is a convenience method, which imports using the default settings. My import ignores the flow fragments.
So I'll build some settings before the import.
Re: Articy import in C#
Posted: Thu Feb 11, 2016 8:57 am
by Tony Li
Sorry about glossing over that in my previous reply. The API reference for ArticyConverter.ConvertXmlToDatabase and related classes are here:
Re: Articy import in C#
Posted: Fri Mar 18, 2016 5:57 am
by irve
I am using some fields for additional conditions and instructions. Would it be possible to make the Articy to Lua script conversions public?