mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: stopping values being reset before OnDestory is called (#2485)
* fix: stopping values being reset before OnDestory is called * matches server side logic * if an object is being fully destroyed it doesn't need its values to be reset
This commit is contained in:
parent
d07c0ceb0a
commit
a51ee1fa3b
@ -951,22 +951,29 @@ static void DestroyObject(uint netId)
|
||||
{
|
||||
localObject.OnStopClient();
|
||||
|
||||
if (!InvokeUnSpawnHandler(localObject.assetId, localObject.gameObject))
|
||||
// user handling
|
||||
if (InvokeUnSpawnHandler(localObject.assetId, localObject.gameObject))
|
||||
{
|
||||
// default handling
|
||||
if (localObject.sceneId == 0)
|
||||
{
|
||||
Object.Destroy(localObject.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
// scene object.. disable it in scene instead of destroying
|
||||
localObject.gameObject.SetActive(false);
|
||||
spawnableObjects[localObject.sceneId] = localObject;
|
||||
}
|
||||
// reset object after user's handler
|
||||
localObject.Reset();
|
||||
}
|
||||
// default handling
|
||||
else if (localObject.sceneId == 0)
|
||||
{
|
||||
// dont call reset before destroy so that values are still set in OnDestroy
|
||||
Object.Destroy(localObject.gameObject);
|
||||
}
|
||||
// scene object.. disable it in scene instead of destroying
|
||||
else
|
||||
{
|
||||
localObject.gameObject.SetActive(false);
|
||||
spawnableObjects[localObject.sceneId] = localObject;
|
||||
// reset for scene objects
|
||||
localObject.Reset();
|
||||
}
|
||||
|
||||
// remove from dictionary no matter how it is unspawned
|
||||
NetworkIdentity.spawned.Remove(netId);
|
||||
localObject.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user