Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Making timeline pause, whenever there is a, UI dialogue textbox.

Discussion in 'Timeline' started by Jayd1Os, Jul 11, 2023.

  1. Jayd1Os

    Jayd1Os

    Joined:
    Mar 27, 2020
    Posts:
    4
    Hello. I am trying to make timeline pause whenever the, dialogue UI textbox is enabled on screen, and resume once the textbox is disabled, I decided to use Signal emitters to call this event through a script that I made. But I am having trouble getting this work, when timeline hits the Signal emitter it pauses and the textbox appears on screen, but for some reason the timeline does not resume when the textbox is set to false. I am entirely sure if this is a bug or if I am doing something wrong, any help?

    Here is what the script looks like
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.Playables;
    4. using UnityEngine.Timeline;
    5.  
    6. [RequireComponent(typeof(SignalReceiver))]
    7. public class DialogueCutscene : MonoBehaviour
    8. {
    9.     [SerializeField] private DialogueUI dialogueUI;
    10.     [SerializeField] private DialogueObject dialogueObject;
    11.     [SerializeField] private PlayableDirector director;
    12.  
    13.     public void ActivateDialogue()
    14.     {
    15.         dialogueUI.ShowDialogue(dialogueObject);
    16.         if (dialogueUI.isOpen)
    17.         {
    18.             Debug.Log("DialogueBox Intiated");
    19.             director.Pause();
    20.         }
    21.         else if(dialogueUI.isOpen == false)
    22.         {
    23.             Debug.Log("DialogueBox Disabled");
    24.             director.Resume();
    25.         }
    26.     }
    27. }
    Skærmbillede 2023-07-11 205007.png
     
  2. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    140
    Did you call
    ActivateDialogue()
    manually when the UI textbox is disabled? The timeline is paused so of-course it would not do anything, including emitting the signal again.
     
  3. daveMennenoh

    daveMennenoh

    Joined:
    May 14, 2020
    Posts:
    112
    Code (CSharp):
    1. if (dialogueUI.isOpen)
    2.         {
    3.             Debug.Log("DialogueBox Intiated");
    4.             director.Pause();
    5.         }
    6.         else
    7.         {
    8.             Debug.Log("DialogueBox Disabled");
    9.             director.Play();
    10.         }
    Your else if is not necessary... if it's notOpen it's not open. Just do the else. I've not tried resume to start the timeline but I know Play works after I pause it.
     
  4. Jayd1Os

    Jayd1Os

    Joined:
    Mar 27, 2020
    Posts:
    4
    I tried this, it didn't work. I did try to debug it, and I noticed that it skips the else statement entirely.
     
  5. daveMennenoh

    daveMennenoh

    Joined:
    May 14, 2020
    Posts:
    112
    Probably because it was open? The code is correct.
     
  6. DuanSanGen

    DuanSanGen

    Joined:
    Apr 13, 2021
    Posts:
    6
    I had made this feature, but I'm not using the Signal track, I used the top Markers track (click on that pin icon to hide/show it), created a SignalAsset and dragged it into the Markers track where I needed to pause and pop up the dialog box,
    and used the Signal Receiver to assign that signal a trigger method. Then in this method, I use the:
    PlayableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0);
    to pause the timeline, and then in the Dialogue object's "Set False" related statement, I use the:
    PlayableDirector.playableGraph.GetRootPlayable(0).SetSpeed(1);
    to continue the timeline play.
    In other words, the closing method of the dialog window (also a way to continue timeline play) occurs outside the timeline control script, like dialogue's own control script.