Speaker name ref?

Fri 3. May 2019, 18:07

Hello again,

I'm setting up a Flow Player in Unity and want to display the speaker's name (of a dialog fragment) in the UI.

I've tried accessing the following variables in DialogueFragment, but none seem to contain the name of the speaker;
> dlgFragment.Speaker.name
> dlgFragment.Speaker.TechnicalName
> dlgFragment.Speaker.ToString()

I also notice that the Manfred demo doesn't show speaker names, just portraits.

Here's one of my dialogue fragments in Unity that shows this character DOES have a name!
https://www.reptoidgames.com/junk/blerp.jpg


So, where is the speaker's name located relative to the DialogueFragment that gets passed in with the ArticyFlowPlayer?


This should be simple... hopefully I'm just missing something obvious! Help would be appreciated. Thanks.
User avatar
ryanmiller
 
Posts: 6
Joined: Mon 29. Apr 2019, 21:15
Location: Toronto, ON

Re: Speaker name ref?

Fri 3. May 2019, 21:41

Ended up solving this by casting the speaker to an Entity.

Code: Select all
var speakerAsset = dlgFragment.Speaker as Entity;
string speakerName = speakerAsset.Unresolved_DisplayName;


Unresolved_DisplayName doesn't seem ideal, but it will do for now!
User avatar
ryanmiller
 
Posts: 6
Joined: Mon 29. Apr 2019, 21:15
Location: Toronto, ON

Re: Speaker name ref?

Mon 6. May 2019, 09:02

Hi ryanmiller,

the value of the Speaker property is an ArticyObject. The problem is, that not every type that inherits from ArticyObject has a display name.

Casting it to an Entity seems to be fine here. The Entity should have the DisplayName property and not just the Unresolved_DisplayName one, otherwise something went wrong with the importer.

Another way to get the display name would be to cast the ArticyObject to an IObjectWithDisplayName.
When you take a look into the generated C# code you will see that the types are implementing a couple of interfaces which can be used to access specific properties dynamically.
Like with other string properties there are possibly two more interfaces, depending on which features are enabled:
- IObjectWithLocalizableDisplayName will give you the localization key instead of the localized display name.
- IObjectWithUnresolvedDisplayName will give you the display name without any processing by the Text Extension feature.


Best regards,

Christian
User avatar
[Articy] Christian Schildt
Articy Staff
Articy Staff
 
Posts: 62
Joined: Tue 16. Jan 2018, 17:03
Location: Bochum

Re: Speaker name ref?

Mon 6. May 2019, 14:34

Thanks for the tips - I'll use these instead. This is a lot more casting than I'm used to!
User avatar
ryanmiller
 
Posts: 6
Joined: Mon 29. Apr 2019, 21:15
Location: Toronto, ON

Re: Speaker name ref?

Tue 7. May 2019, 07:51

This is a lot more casting than I'm used to!


Yes it can take some time to get used to this. But if you think about the fact, that you can actually disable some properties in articy:draft this approach makes a bit more sense. Especially if you also consider that a lot of object share certain properties but don't really have or can have (because of dynamically disabling properties) common base classes.

So as a rule of thumb: Each object type has an inheritance hierarchy of 3. All share ArticyObject, then the actual Object type hardcoded in articy:draft(Like FlowFragment, Jump, Instruction, Entity), and optionally your created templates(Like Character). Using the IObjectWithXYZ interface is only necessary once you try to write more managable and reusable code.

Unresolved_DisplayName doesn't seem ideal, but it will do for now!


As Chris mentioned, for each Unresolved_XYZ or Localized_XYZ property there is also an XYZ property. Localized is only there if you enabled localization, otherwise the code generation will leave it out. Unresolved returns the raw string you entered into articy:draft for the object. Which sounds exactly what you where looking for, until you use our text extensions then your XYZ property returns the resolved string, and Unresolved_XYZ well you guessed it. So in short: Using XYZ is in most cases what you are looking for, unless you actually need the helper properties.

Hope that helps :)
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 18 guests

Who We Are
Contact Us
Social Links