Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

Add "Destroy With Scene" checkbox in inspector for NetworkObject #2967

Open AlexEnnerfelt opened 5 months ago

AlexEnnerfelt commented 5 months ago

Is your feature request related to a problem? Please describe.

I have a game where I load a Logic scene where I keep the Player objects and GameMode Managers, then I load an Environment scene where I spawn items like loot drops, enemies etc.

Then when I unload the environment all of the spawned enemies and other environment related objects are moved to my Logic scene because it is the Active scene, but I would like for them to be destroyed with the scene they are a part of.

Describe the solution you'd like It would be useful to be able to set "destroyWithScene" from the inspector and saved to the prefab.

Describe alternatives you've considered My current solution to this is to set "destroyWithScene = true" from my custom spawn manager, but there might be cases where I do not want this behaviour.

NoelStephensUnity commented 4 months ago

Hi @AlexEnnerfelt,

Do you have Active Scene Synchronization enabled on the network prefab(s) of the NetworkObject(s) that is/are being migrated?

AlexEnnerfelt commented 1 month ago

Hi @AlexEnnerfelt,

Do you have Active Scene Synchronization enabled on the network prefab(s) of the NetworkObject(s) that is/are being migrated?

No I do not

NoelStephensUnity commented 1 month ago

I will see if I can get that update into the queue. It does seem like it would be useful to be able to set that in the inspector view.