Working with IObjectLocalizableText

Mon 29. Jul 2019, 12:42

Hello,

I am currently setting up the FlowPlayer with Unity, and I have encountered a small problem regarding a piece of code in my flow manager.
At one point, I check if the paused object has a localizable text, with:
Code: Select all
if (modelWithText != null && aObject is IDialogueFragment)
{
     dialogText.LocaKey = modelWithText.LocaKey_Text;
}

(I am working on a code made by someone else, thus I don't know if this piece is originally brought by Articy)
At the end of this if process, the CloseDialogue() is called, which allows the flow to resume.

However, this if statement is also checked by any kind of nodes, including hubs or jumps, which completely makes them skip their pause.
You can see here that I forced the statement to only include my dialogues, which are the only displayed texts for the moment. But this isn't optimal, as I may need to display things at other points in my game. I guess I could then check for all types of nodes displaying text, but you can see how unpractical this will become.

So, here's my question:
How can I make sure that only objects with Localizable Texts get checked in this function?
Or maybe this is something I could just change directly in Articy?

TL;DR:
I can't make IObjectwithLocalizableText work, or there is something I don't understand in this.

Thank you in advance!
AlexandreOct
 
Posts: 4
Joined: Tue 16. Jul 2019, 15:05

Re: Working with IObjectLocalizableText

Tue 30. Jul 2019, 09:02

Hi AlexandreOct,

If you don't need to deal with hubs or jumps at all, i would remove them from the PauseOn mask, so the flow player will auto play automatically. If you need those, then you have to check if you encountered those.
But it is totally fine to just check for an interface on the paused object and do something accordingly. The performance impact is negligible for those tests.

You don't have to use if else at this point of course, you could use a more clever approach with a prebuilt dictionary where the key is your articy type and the value is a strategyregistered to deal with the type. This approach would allow you to switch the registered strategies quickly. But this is software design and heavly dependant on what you want to do and what you need.
I had somewhere a code snippet(can't find it anymore) where i used StartCoroutine and different methods like (PausedOnFlowFragment, PausedOnDialogueFragment) etc. with the appropriate type as an argument utilizing unitys StartCorountine method lookup to do the selecting of the method for me. Obviously less performant than the if solution, but maybe a bit more readible for some people.

How can I make sure that only objects with Localizable Texts get checked in this function?
Or maybe this is something I could just change directly in Articy?


Imo you are already doing it, you could design a more clever framework around it, but that depends on your needs.

Hope that helps, if you have more questions let me know

Best regards

Nico
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

Re: Working with IObjectLocalizableText

Tue 30. Jul 2019, 10:19

Thank you for your answer,
I think I will do just as you said, checking the type of node directly.

Also I just realized that I skipped a line of code from my exemple, sorry about that...
Code: Select all
var modelWithText = aObject as IObjectWithLocalizableText;
if (modelWithText != null && aObject is IDialogueFragment)
{
     dialogText.LocaKey = modelWithText.LocaKey_Text;
}


There's still a small thing that I don't understand, why is it that all nodes successfully check that condition? Something like a hub or a jump have a name, but is that enough to be considered a localizable text? Right now, modelWithText is never null, i can remove it and nothing changes.
Is there a property or object type that would be more suited for this obective of localization ?
AlexandreOct
 
Posts: 4
Joined: Tue 16. Jul 2019, 15:05

Re: Working with IObjectLocalizableText

Tue 30. Jul 2019, 11:30

There's still a small thing that I don't understand, why is it that all nodes successfully check that condition?
Something like a hub or a jump have a name, but is that enough to be considered a localizable text?


The name you are talking about is DisplayName(check IObjectWithLocalizableDisplayName) but yes, jumps and Hubs also have Text. In articy:draft you find these in their corresponding model sheet on the General Page called Description.
I just decided to generalize it under Text in the plugin to merge it with Description and SpokenText(or FullText).

Right now, modelWithText is never null, i can remove it and nothing changes.


InputPin and OutputPin, if set as pauses, would make this check fail. Also if you decided to configure your ruleset export in articy:draft and remove the Text property from some or all objects, this test would also fail.

Is there a property or object type that would be more suited for this obective of localization ?


Not sure what you mean by that. This approach is the prefered way to deal with localization.

Hope that helps

Nico
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 Technical Discussion

Who is online

Users browsing this forum: No registered users and 22 guests

Who We Are
Contact Us
Social Links