2D Toolkit Forum
2D Toolkit => Support => Topic started by: pandaryll on August 21, 2013, 04:04:32 pm
-
Whenever I reload the scene using Application.LoadLevel(Application.loadedLevel) the UI camera of my Tk 2D UIManager becomes missing.
Here's the error message:
MissingReferenceException: The object of type 'Camera' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Camera.ScreenPointToRay (Vector3 position) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/UnityEngineCamera.cs:376)
tk2dUIManager.CheckInputs () (at Assets/TK2DROOT/tk2dUI/Code/Core/tk2dUIManager.cs:388)
tk2dUIManager.Update () (at Assets/TK2DROOT/tk2dUI/Code/Core/tk2dUIManager.cs:236)
The game will still run but the error persists.
-
You can try creating a script and added to the camera with:
DontDestroyOnLoad (gameObject);
Maybe UIManager already has it, and lose the reference of the camera.
-
What version of 2D Toolkit are you using?
-
I'm using 2 final + hotfix 2 (taken from 2D Toolkit > About)
The camera isn't actually destroyed in the scene but somehow the UI manager loses it reference of it
-
This is more complicated than it should be, but this has been sorted in the next release.
Do you have the tk2dUIAudioManager on the same object?
Whats happening is
tk2dUIManager -> camera1
when you reload, camera1 gets destroyed and recreated, but since uimanager is not destroyed, its still pointing to camera1.
The easiest way around this right now, is to simply assign camera1 to uimanager immediately after loading.
-
that did the trick thanks!