Articy Forum


https://www.articy.com:443/forum/

ArticyFlowPlayer: Support ArticyObject on startOn Property

https://www.articy.com:443/forum/viewtopic.php?f=46&t=19062

Page 1 of 1

ArticyFlowPlayer: Support ArticyObject on startOn Property

Posted: Fri 29. Nov 2019, 17:56
by shanehou
Hi,

I'm using the ArticyFlowPlayer in Unity but found only ArticyRef is supported on startOn property. I feel that causes some inconvenience. For example, if I have a dialogue to play, what I can do is to set its reference in Unity Inspector, and make a prefab that runs the dialogue. However, if I have like 100 or 1,000 dialogues to play, it becomes very inconvenient to create 1,000 prefabs for each of them, with an ArticyFlowPlayer on every prefab referencing each one of them in Unity and load one of the prefabs in runtime.

An easy solution would be to call ArticyDatabase.GetAllOfType<TObject>(), and maintain a dictionary so I can find the ArticyObject when I need any of them. But since the ArticyFlowPlayer only supports ArticyRef, methods in the ArticyDatabase class only returns ArticyObject, and I couldn't find a workaround except for the 1,000 prefabs solution, I'm keen to know if there's a better solution for this :D

Thanks,
Shane

Re: ArticyFlowPlayer: Support ArticyObject on startOn Proper

Posted: Mon 2. Dec 2019, 09:22
by [Articy] Nico Probst
Hi shanehou,

i'm not sure what you want to do. ArticyRef can reference any ArticyObject, like FlowFragment, Dialogues etc. You don't have to set ArticyRef in the Inspector, you can very easy set it to any ArticyObject reference in code. The reason its an ArticyRef is to not lose a strong reference to it, when your reimport the database and your ArticyObject would be re-created.
It behaves almost the same. And by almost i mean you have to call GetObject() to get the underlying object.
Now obviously you only need a single prefab at most for your dialogues, and just re-set the StartOn property (please use the upper case property when calling in code) everytime you want to start from a new Dialogue. No need for a new flow player for each instance.

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

Best regards

Nico

Re: ArticyFlowPlayer: Support ArticyObject on startOn Proper

Posted: Mon 2. Dec 2019, 16:50
by shanehou
[Articy] Nico Probst wrote:Hi shanehou,

i'm not sure what you want to do. ArticyRef can reference any ArticyObject, like FlowFragment, Dialogues etc. You don't have to set ArticyRef in the Inspector, you can very easy set it to any ArticyObject reference in code. The reason its an ArticyRef is to not lose a strong reference to it, when your reimport the database and your ArticyObject would be re-created.
It behaves almost the same. And by almost i mean you have to call GetObject() to get the underlying object.
Now obviously you only need a single prefab at most for your dialogues, and just re-set the StartOn property (please use the upper case property when calling in code) everytime you want to start from a new Dialogue. No need for a new flow player for each instance.

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

Best regards

Nico


Hi Nico,

Thanks a lot! The StartOn property is literally what I'm looking for. What I'm doing is using code like below to load ArticyObjects in runtime:

Code: Select all
    Dictionary<string, CustomFlowTemplate>() _dayFlowDict = new Dictionary<string, CustomFlowTemplate>();

    List<CustomFlowTemplate> dayflows = ArticyDatabase.GetAllOfType<CustomFlowTemplate>();
    foreach (CustomFlowTemplate temp in dayflows)
    {
      _dayFlowDict.Add(temp.DisplayName, temp);
    }


So I just need to make sure to name every flow correctly by using a specific rule, then I may find the flow I need by using its display name and load it in a FlowPlayer. That saves me some extra effort to create separate Unity prefabs for each flow. Could you let me know if there's any potential technical risk of doing this?

By the way, the reason for using a new flow player for each instance is that in our game, we need several dialogues to be played simultaneously and independently(imagine if you're using WhatsApp and talking with some people at the same time). I understand it's a very uncommon usage :)

Thanks a lot!
Shanehou

Re: ArticyFlowPlayer: Support ArticyObject on startOn Proper

Posted: Tue 3. Dec 2019, 09:50
by [Articy] Nico Probst
So I just need to make sure to name every flow correctly by using a specific rule, then I may find the flow I need by using its display name and load it in a FlowPlayer. That saves me some extra effort to create separate Unity prefabs for each flow. Could you let me know if there's any potential technical risk of doing this?


I would use the TechnicalName, as the DisplayName could be translated. Other than that, this approach should work.

By the way, the reason for using a new flow player for each instance is that in our game, we need several dialogues to be played simultaneously and independently(imagine if you're using WhatsApp and talking with some people at the same time). I understand it's a very uncommon usage


Hehe, no its fine! One of the reason why i wanted to keep being able to have multiple flow players in the first place. So yes instantiate your prefab with the flow player, and set the StartOn property should work fine.

All times are UTC
Page 1 of 1