Articy Forum


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

How the branchs in IArticyFlowPlayerCallbacks is ordered?

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

Page 1 of 1

How the branchs in IArticyFlowPlayerCallbacks is ordered?

Posted: Mon 4. Dec 2017, 18:12
by misterionkell
While running in Articy we always have answers in vertical aligned order - as see it in Articy flow so i see in preview. But in Unity we have unpredictible branch ordering.
Here is also sample articy flow - https://monosnap.com/file/o2CCJiXo66kDKQ1l9YrK5KB1MNnbfq (link to image service becouse of forum image size limits to 800px):
- In Articy presentation we have branch order 1,2,3,4.
- In Unity we have branch order - 3,1,2,4.

Is here some documentation or rules of ordering for IArticyFlowPlayerCallbacks.OnBranchesUpdated(IList<Articy.Unity.Branch>) method?

Re: How the branchs in IArticyFlowPlayerCallbacks is ordered

Posted: Tue 5. Dec 2017, 13:34
by [Articy] Nico Probst
Hi misterionkell,

its true, the plugin itself has no sorting and it usually ends up being the order of creation of the connections. But you can easily adjust to that by sorting the available branches in OnBranchesUpdated.

Code: Select all
public class BranchComparer : IComparer<Branch>
{
   int IComparer<Branch>.Compare(Branch x, Branch y)
   {
      var nodeX = x.Target as IObjectWithPosition;
      var nodeY = y.Target as IObjectWithPosition;
      return nodeX.Position.y.CompareTo(nodeY.Position.y);
   }
}

public static BranchComparer sBranchComparer = new BranchComparer();

public void OnBranchesUpdated(IList<Branch> aBranches)
{
   List<Branch> sorted = new List<Branch>(aBranches);
   sorted.Sort(sBranchComparer);
   
   // ...
}


Something like this should do the trick. Please keep in mind that this only works if your PausedOn are always nodes, if you stop on pins you have to adjust the Comparer accordingly.
I add this to our feature list to provide a builtin sorting.

Best regards

Nico

Re: How the branchs in IArticyFlowPlayerCallbacks is ordered

Posted: Wed 31. Jul 2019, 12:20
by btsslawa
Has this feature been included as of now, if so, how does it look like?

Re: How the branchs in IArticyFlowPlayerCallbacks is ordered

Posted: Wed 31. Jul 2019, 16:22
by [Articy] Nico Probst
Hi btsslawa,

no. The solution is basically what we would add anyway, and it is maybe not right for everyone. And as it is rather quick to add yourself, we just left it like it is.

Best regards

Nico

All times are UTC
Page 1 of 1