unity-game-enginebuttontimedelay

How do i create a time delay before the button appears unity


I am creating an interactive video using Unity/C#. I am doing this using scenes and buttons that when clicked, go to the next scene or back. However, I want the buttons to appear once the video is finished. Is there any way I can add a delay to the buttons before they appear in the scene when playing?


Solution

  • For time delay you could use coroutines. Check it out here There is options like waitforseconds so you can delay your button apperance. here is sample code

    private IEnumerator ShowBtn()
    {
        yield return new WaitWhile(() => videoplayer.isPlaying);
        // show visibility of your button
    }
    

    And when you play video call this function like this

    StartCoroutine(ShowBtn());