Movie texture plays in scene and game view only

I am new to C# and Unity. So far I have built a 2D platformer and I am almost finished with my game.This is my first time posting to the forum and I have tried looking for a similar question like mine. If I am missing a detail please let me know. I am trying to put up as much info as I can think of that will help.

I have two movie texture codes. One is the introduction scene that plays when the player first starts the game. In game view, scene and game view, and in the build, this works perfectly! However, with my second code I have a trigger that sets off the movie texture at the end of each level. All I did was changed the introduction code to start with a trigger. The problem is that with the triggered code the movie texture will only play when I have both the scene view and game view open. When I maximize the game view or make a build, the movie texture will not trigger at all. (The inspector is set up the same way for both intro and triggered movie textures.)

Introduction movie texture code:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

[RequireComponent (typeof(AudioSource))] // allows you to play audio with movie texture

public class IntroCam : MonoBehaviour {
    public MovieTexture movie;
    public new AudioSource audio;

    public string levelToLoad;

    void Start()
    {
        GetComponent<RawImage>().texture = movie as MovieTexture;
        audio = GetComponent<AudioSource>();
        audio.clip = movie.audioClip;
        movie.Play();
        audio.Play();

        Invoke("nextscene", 5);
    }

    void nextscene()
    {
        SceneManager.LoadScene(levelToLoad);
    }
  
}

!(http://Alt text) !(http://Alt text)

Triggered movie texture code:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

[RequireComponent(typeof(AudioSource))]

public class IntroCamV02 : MonoBehaviour {
    public MovieTexture movie;
    private new AudioSource audio;

    public string levelToLoad;
    void Start()
    {
            GetComponent<RawImage>().texture = movie as MovieTexture;
            audio = GetComponent<AudioSource>();
            audio.clip = movie.audioClip;
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        //((MovieTexture)GetComponent<Renderer>().material.mainTexture).Play();
        movie.Play();
        audio.Play();
       
        Invoke("nextscene", 10);
    }

    void nextscene()
    {
        SceneManager.LoadScene(levelToLoad);
    }
}

Any help would be greatly appreciated. :slight_smile:

You code looks okay.

Try making a Debug.Log in OnTriggerEnter2D and see if it gets called at all - my guess is that it’s never invoked and you might have to go through the scene and check that the 2d colliders are working as they should.

Also, bear in mind that you’re are maybe loading a scene as playing a movie at the same time? Maybe the Movieplayer might be destroyed if you dont make sure that the Intromovie is flagged as “DontDestroyOnLoad” in Awake.

Thank you~ I can’t believe that I didn’t think before to add a debug log. As you mentioned, when the game and scene view are both opened the trigger was invoked. However, when I had the game view maximized it wasn’t being invoked. I am now in the process of working with the colliders…there has to be something that I am missing.