Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to destroy camera from previous scene?

Discussion in 'Scripting' started by Smiaro, Jan 10, 2016.

  1. Smiaro

    Smiaro

    Joined:
    Jul 22, 2013
    Posts:
    19
    Hello,
    I am working on many scenes. But I have problem just in one of them. In the next scene, I have two Main Cameras, one from current scene and one from previous. How to fix that and delete previous?

    The one and only difference is that I have Kinect/FaceTrackingManager added to that scene from I have camera in next.

    Probably error comes from here:
    Code (csharp):
    1. void Start()
    2.  
    3. {
    4.  
    5. gestureListener = Camera.main.GetComponent<GestureListener>();
    6.  
    7. faceTrack = Camera.main.GetComponent<FacetrackingManager>();
    8.  
    9. mainCam = Camera.main;
    10.  
    11. StartCoroutine(Play1(mySource1));
    12.  
    13. }
    14.  
     
  2. specterdragon

    specterdragon

    Joined:
    Dec 30, 2013
    Posts:
    21
    It's hard to say without seeing a lot more code. I'm assuming it's a single scene load, not an additive load. It seems like the easier solution might be to manually destroy the leftover camera when the new scene loads. That doesn't solve the problem of why it's not destroyed in the first place but it might be a workable answer until you find the root cause.