Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Camera doesn't destroy after Scene

Discussion in 'Editor & General Support' started by Smiaro, Jan 9, 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.  
     
    Last edited: Jan 9, 2016
  2. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    In case of multiple scenes, don't use the MainCamera as a component holder for Kinect-related components. It is kept alive across the scenes, which is causing double cameras in your case. See Howto-Use-KinectManager-Across-Multiple-Scenes.pdf - somewhere in the package.
     
  3. Smiaro

    Smiaro

    Joined:
    Jul 22, 2013
    Posts:
    19
    Of course @roumenf I know that PDF, but there is "In order to use KinectManager across multiple scene". That is what I have in my project, I mean basic Kinect Manager. So if I need Facetracking Manager only in one of scenes, should that manager be also attached to Game Object in startup scene and stored across all scenes or there is another way?
     
  4. roumenf

    roumenf

    Joined:
    Dec 12, 2012
    Posts:
    635
    If you need the face-tracking in one scene only, then open KinectScripts/FacetrackingManager.cs and in its StartFacetracker()-method, comment out this line: 'DontDestroyOnLoad(gameObject);'. Also, rename the OnApplicationQuit()-method to OnDestroy().
     
    Smiaro likes this.
  5. Smiaro

    Smiaro

    Joined:
    Jul 22, 2013
    Posts:
    19
    And that's what I need. Thank you :)