- Home /
The 3D camera no longer exists -> AudioListener Spam
Hey, I am encountering a problem.
I am in a 2D environement!
This is the scenario: If a player reaches the goal he is able to choose what he wants to do next. One option is to repeat the level. Therefore there is a button which will just load the SAME scene again.
If he retrys the level now and draws a line there is a warning:
The 3D camera no longer exists...if you have changed scenes, ensure that SetCamera3D is called in order to set it up.
Therfore I have a script which says that the camera should not be destroyed on load.
The game pretty much works again and the error above will not appear anymore BUT I then have 2 (3,4,5 depending on how many times I reloaded the level) Aadio listeners in the scene and get warnings spammed which probably affects the games performance because the more I retry the level the more laggier it gets.
If you need any further information be sure to leave a comment!
If you have a solution or suggestion it is really appreciated.
Kindly regards, René
Answer by screenname_taken · Dec 07, 2014 at 10:12 PM
Is your listener in the singleton object? (an object that you save and don't destroy on level reset). If yes, then you should have an if check to see if it's already alive. If it is, kill it.
Upon further investigation of the problem I realised that the real problem is that the Draw Calls double if I keep the old camera on load (obviously -.-) and therefore have get performance problems.
The reason I need the "DontDestroyOnLoad" for the camera is this error:
The 3D camera no longer exists...if you have changed scenes, ensure that SetCamera3D is called in order to set it up. UnityEngine.Debug:LogError(Object) Vectrosity.VectorLine:LogError(String) Vectrosity.VectorLine:Line3DDiscrete(Int32, Int32, $$anonymous$$atrix4x4, Boolean) Vectrosity.VectorLine:Draw() LineObject:UpdateLine() (at Assets/Draw Shapes for 2D Physic Game/Scripts/LineObject.cs:49) LineObject:Update() (at Assets/Draw Shapes for 2D Physic Game/Scripts/LineObject.cs:36)
which I do not know how to solve other than not to destroy the camera on load.
Note: I am using a drawing asset which has vectrosity included(?)
Your suggestion is good but would not solve the problem at the roots. So If you have any idea on how to solve this I would be very greatful.
Answer by boazunity · Sep 03, 2016 at 01:31 PM
you need to use this line...
void Start () {
VectorLine.SetCamera(Camera.main);
// or
VectorLine.SetCamera3D(Camera.main);
}