Search Unity

Timeline Scripting Audio

Discussion in 'Animation' started by Bentoon, Oct 14, 2019.

  1. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
    Hello
    I have a timeline animating objects with a lot of Signal emitter / marker Pausing the timeline (like a break point) until the user does something that advances it to the next signal marker pause etc...

    Works well. But,

    What I want are audio clips to advance the timeline between pause emitters...

    So audio would play in between for a minute or two between the signal markers pause... and at the end of audio the script sends a play() to timeline to advance to the next etc...

    I have this working on the first clip added to timeline (as an activated audio game object)

    the "End of sound" is printed to Console after the first,
    but it doesn't work past that:


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Playables;
    5. using UnityEngine.Timeline;
    6.  
    7. public class endOfAudioPlay : MonoBehaviour
    8. {
    9.  
    10.     public AudioSource nameClip;
    11.     public PlayableDirector playDirectorOBJ;
    12.  
    13.     void Start()
    14.     {
    15.         nameClip.Play();
    16.         StartCoroutine(endAudio());
    17.     }
    18.  
    19.  
    20.     private IEnumerator endAudio()
    21.     {
    22.         yield return new WaitForSeconds(nameClip.clip.length);
    23.         Play();
    24.         print("end of sound");
    25.  
    26.     }
    27.  
    28.     public void Play()
    29.     {
    30.         playDirectorOBJ.Play();
    31.     }

    I hope that's clear,

    Seems like it should be simple. : o


    ~be
     
    Last edited: Oct 14, 2019