Search Unity

Video How to switch scenes after a video is over

Discussion in 'Audio & Video' started by lsk111919, Aug 28, 2020.

  1. lsk111919

    lsk111919

    Joined:
    Jul 8, 2020
    Posts:
    19
    Code (CSharp):
    1. }
    2. [*]using System.Collections;
    3. [*]using System.Collections.Generic;
    4. [*]using UnityEngine.SceneManagement;
    5. [*]using UnityEngine;
    6. [*]using UnityEngine.Video;
    7. [*]public class Videoorigin : MonoBehaviour
    8. [*]{
    9. [*]    public VideoPlayer mVideoPlayer = null;
    10. [*]    float time = .0f;
    11. [*]    void Start()
    12. [*]    {
    13. [*]
    14.  
    15. [*]    }
    16. [*]    private void Awake()
    17. [*]    {
    18. [*]        mVideoPlayer.loopPointReached += App;
    19. [*]    }
    20. [*]    void App(VideoPlayer player)
    21. [*]    {
    22. [*]        time += Time.deltaTime;
    23. [*]        if (time >= 5 * 60)
    24. [*]        {
    25. [*]            SceneManager.LoadScene("MainScenes");
    26. [*]        }
    27. [*]    }
    28. [*]}
    29.  
    30.  
    31.  
    I'd like to have the scene switched after 5 minutes. What should I do?

    I'm sorry if the explanation is insufficient or the grammar is wrong.
     
    Last edited: Aug 31, 2020
  2. harini

    harini

    Unity Technologies

    Joined:
    May 28, 2015
    Posts:
    45
    Hi,
    If I understand you correctly, you would first like to play the video completely and then load the scene once the video has finished playing? If so, can you try without the "if" statement and make sure that the scene "MainScenes" is added to the build settings.
    Code (csharp):
    1.  
    2. void App(VideoPlayer player)
    3.     {
    4.             SceneManager.LoadScene("MainScenes");
    5.     }
    6.  
    Thanks and regards,
    Harini
     
  3. lsk111919

    lsk111919

    Joined:
    Jul 8, 2020
    Posts:
    19
    I forgot to ask you one more question. I'm sorry. I want to go back to the main screen 5 minutes after the video is played.
     
    Last edited: Aug 31, 2020