Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?) The following scene GameObjects were found: <unnamed>)
Hi,
I have a problem while using ITeardownSystem
`
void Awake()
{
m_StartSceneSystem = new StartSceneSystems(Contexts.sharedInstance);
m_StartSceneSystem.Initialize();
}
// Update is called once per frame
void Update()
{
m_StartSceneSystem.Execute();
m_StartSceneSystem.Cleanup();
}
private void OnDestroy()
{
m_StartSceneSystem.DeactivateReactiveSystems();
m_StartSceneSystem.TearDown();
}
When I change to new Scene unity throw me an error that
Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?) The following scene GameObjects were found: unnamed)
If I have 5 entities on current scene so I will have 5 unnamed in that error! And then if I disable Teardown the error will disappear so I guest TearDown is reason.
Please help me with this error, thank you so much!
can you provide more source code? why you need to call Initialize() execute() cleanup() and teardown() on Monobehavior?
Seems strange to be controlling one individual system from a monobehaviour like that - have you looked at the GameController.cs in match-one? Look at GameSystems too.
Guess it caused by unity visual debug
What does your Teardown system do? Can you post a minimal project that reproduces this?
Sorry, I don't have computer couple days ago so I can't reply this thread. I try to build my game to android phone and use adb log for debug but this error not show off so I think it is bug of unity visual debug. Btw, my Teardown system use for destroy all exist entities before changing scene, this is my code for this
public class TeardownGameEntity : ITearDownSystem
{
private Contexts m_Contexts;
public TeardownGameEntity(Contexts _Contexts)
{
m_Contexts = _Contexts;
}
public void TearDown()
{
m_Contexts.game.DestroyAllEntities();
}
}
Thank you for all of your supports and sorry for late reply
I use Context.sharedInstance in OnDestroy() method. That's the reason for my bug. See more http://robamemo.hatenablog.com/entry/2018/01/11/195311