Scene manager

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
achuchon
Posts: 5
Joined: Sat Feb 03, 2024 3:23 pm

Scene manager

Post by achuchon »

Hello toni and community! I tell you, I have the pixel crushers scene loader system to change scenes with the loading screen, everything works perfectly, but I tried to add a scene as the first scene that is a cinematic, my intention is that when this scene ends the video changes to the first scene with the loading screen again, but I can't do it. please help
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scene manager

Post by Tony Li »

Hi,

If I understand you correctly, you want to change scenes after a video has finished playing. This may require a short script. Maybe something like:

Code: Select all

using System.Collections;
using UnityEngine;
using UnityEngine.Video;
using PixelCrushers;

public class LoadSceneAfterVideo : MonoBehaviour
{
    public VideoPlayer introVideo; // Assign these in inspector
    public string nextSceneName;

    private IEnumerator Start()
    {
        // Wait for video to start:
        while (!introVideo.isPlaying) { yield return null; }

        // Wait for video to end or player to cancel:
        bool cancelVideo = false;
        while (introVideo.isPlaying && !cancelVideo) 
        {
                if (InputDeviceManager.IsKeyDown(KeyCode.Escape)) cancelVideo = true;
            }
            yield return null; 
        }
            
        // Load next scene:
        SaveSystem.LoadScene(nextSceneName);
    }
}
achuchon
Posts: 5
Joined: Sat Feb 03, 2024 3:23 pm

Re: Scene manager

Post by achuchon »

Thankyou Tony works fine, one question my dialogue system runs with new input sistem, y changed this line
if (InputDeviceManager.IsKeyDown(KeyCode.Escape)) cancelVideo = true;
to if (Input.GetButtonDown("Cancel")) cancelVideo = true;

but the video keeps canceling with escape instead of cancel, (cancel is the tab key in my inputmap)
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scene manager

Post by Tony Li »

If you're using the Input System, change this:

Code: Select all

if (InputDeviceManager.IsKeyDown(KeyCode.Escape))
to:

Code: Select all

if (InputDeviceManager.IsButtonDown("Cancel"))
and register "Cancel" with the Input Device Manager as shown in the Dialogue System's Input System tutorial video or page 5 of Input_Device_Manager_Manual.pdf included in the Dialogue System.
Post Reply