#What's the right way to restart game?

1 messages · Page 1 of 1 (latest)

patent tundra
#

Hi everyone,

I've tried restart my game by unload all sub scenes (one Game Scene and a few EntityPrefab Scenes) by SceneSystem.UnloadScene()

But there are still some entities left (these entities is created by EntityManager.CreateEntity()

So what's the right way to clear all the entities in the world and restart game?

tender rampart
#

you need to design restart all by yourself

#

at worst you can just recreate world

patent tundra
#

Hi Issue,

I've checked and the entities created by EntityManager.CreateEntity() don't have any SceneTag component.

Only Entities created by EntityManager.Instantiate() have a SceneTag component.

So we have to manually add SceneTag component to entities created by EntityManager.CreateEntity()?

patent tundra
#

Perhaps I should recreate the world to clear all the entities

tender rampart
#

I'd suggest to just keep track of all such entities

#

and manually destroy/reset them

#

usually CreateEntity is only used for singletons

#

so that's rarely a problem

patent tundra
#

ok thank you!
I got it 😄

#

Hopefully Unity will make it as simple as before

tender rampart
#

what's not simple about it?

#

🤔

patent tundra
#

As you just said we have to manually destroy/reset all entities now.

tender rampart
#

and what was before?

patent tundra
#

We only need to call SceneManager.LoadScene to restart game using old GameObject scene.

So I thought that we could just reload scene to restart game using Entity Scene

tender rampart
#

and you don't use additive scenes

#

and still

#

that kind of results in you losing all GO managers

#

which makes you do opposite: ensure they stay alive