UI Demo Advanced

This sample scene demonstrates some common UI stuff that can be done with some advanced usage of Sequentior.
Child game objects of SEQUENTIALS game object in the scene have Sequentior Manager components which you can examine and learn how they work.
Starting Sequentior

This sequentior will play automatically on start.
It basically plays other sequentiors one by one with some delays.
Dynamic Dialog Sequentior

This is a little bit complicated but it demonstrates a powerful mechanism to integrate sequentials with custom code.
In this sequentior, we want to reveal dialog texts with animation. This can be done simply by adding a Reveal Text Sequential and setting the text to reveal. But in this project we're getting the texts of the dialogs dynamically at runtime. So we need a Variable to be defined in the Sequentior Manager.

Here we've added a variable named DialogText with String data type. And we set the Text option of the Reveal Text Sequential to variable and assign it DialogText by using Value Assign Options.
Now, what we need to do is to assign values to this DialogText variable from our custom script.
/// <summary>
/// This will be called from Reveal Text Sequentials
/// </summary>
public void ConsumeDialogText()
{
// SeqDialog sequentior should have a string variable named DialogText
var dialogTextVar = SeqDialog.GetVariable("DialogText");
if (dialogTextVar != null && currentDialogTextIndex < DialogTexts.Length)
{
// set the sequentior variable to the current dialog text
// look at the SeqDialog to see some sequentials (e.g. Reveal Text) using this variable to get the values
dialogTextVar.StringValue = DialogTexts[currentDialogTextIndex];
// and get the next one ready
currentDialogTextIndex++;
}
}
As you see, in ConsumeDialogText() method, we get the current dialog text from the DialogTexts property of UIDemoAdvancedManager script of UI Demo Manager game object in the scene. And we call the ConsumeDialogText() method from our Sequentior by Unity Event Trigger Sequential. When this sequential plays as the first sequential inside the Loop Sequential.

Dynamic Sequentior
In this project, we use Dynamic Sequentiors for displaying popups because every popup uses the same animations for show and hide mechanisms. So we define sequentior prefabs for each animations (UIDemoAdvanced > Prefabs > Sequential Prefabs) and play these sequentiors for any popup.
To instantiate one of these sequentior prefabs, we've defined a method in UIDemoAdvancedManager class:
/// <summary>
/// Instantiates a sequentior from a prefab
/// </summary>
/// <param name="seqPrefab"></param>
/// <returns></returns>
public SequentiorManager InstantiateSequentior(SequentiorManager seqPrefab)
{
var seqInstantiator = GetComponent<SequentiorInstantiator>();
seqInstantiator.SequentiorPrefab = seqPrefab;
return seqInstantiator.InstantiateSequentior(this);
}
For example, below is the sequential used for closing a popup game object:

As you see, we set the Get Target Object By parameter to Variable and set the Target Object Variable to Popup. So whenever we need to close a popup we need to set this Popup variable to the popup we want to close.
/// <summary>
/// Closes a popup by instantiating a Sequentior Manager prefab
/// </summary>
/// <param name="popup"></param>
public void ClosePopup(GameObject popup)
{
// instantiate the close popup sequentior and hold it in a var
var seqPopup = InstantiateSequentior(SeqClosePopupPrefab);
// set the Popup gameobject variable to the popup because this sequentior gets the Target Object from a variable named Popup.
// see the sequentior manager in Prefabs/Sequential Prefabs
seqPopup.GetVariable("Popup").VariableObj = popup;
}
This is how we control the dynamic (prefab) sequentiors from our scripts.
Popup Animation Global Variable
Also, you'll see that the Duration parameter of the Scale UI Sequential in Open Popup and Close Popup sequentior prefabs above is set to a Global Variable by using Value Assign Options.
We've created a global variable named GlobalVar Popup Open Close Duration in UIDemoAdvanced > Global Variables folder and set the Duration to this global variable.


This way, we've created a way to control the duration of the open and close animations for all popups in this project. So if we think the popups opens too slow or too fast, we just need to modify the value of the global variable and that's it!
Note
You can learn more about global variables by clicking here.