mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00: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,23 +951,30 @@ static void DestroyObject(uint netId)
|
|||||||
{
|
{
|
||||||
localObject.OnStopClient();
|
localObject.OnStopClient();
|
||||||
|
|
||||||
if (!InvokeUnSpawnHandler(localObject.assetId, localObject.gameObject))
|
// user handling
|
||||||
|
if (InvokeUnSpawnHandler(localObject.assetId, localObject.gameObject))
|
||||||
{
|
{
|
||||||
|
// reset object after user's handler
|
||||||
|
localObject.Reset();
|
||||||
|
}
|
||||||
// default handling
|
// default handling
|
||||||
if (localObject.sceneId == 0)
|
else if (localObject.sceneId == 0)
|
||||||
{
|
{
|
||||||
|
// dont call reset before destroy so that values are still set in OnDestroy
|
||||||
Object.Destroy(localObject.gameObject);
|
Object.Destroy(localObject.gameObject);
|
||||||
}
|
}
|
||||||
|
// scene object.. disable it in scene instead of destroying
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// scene object.. disable it in scene instead of destroying
|
|
||||||
localObject.gameObject.SetActive(false);
|
localObject.gameObject.SetActive(false);
|
||||||
spawnableObjects[localObject.sceneId] = localObject;
|
spawnableObjects[localObject.sceneId] = localObject;
|
||||||
}
|
// reset for scene objects
|
||||||
}
|
|
||||||
NetworkIdentity.spawned.Remove(netId);
|
|
||||||
localObject.Reset();
|
localObject.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove from dictionary no matter how it is unspawned
|
||||||
|
NetworkIdentity.spawned.Remove(netId);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (logger.LogEnabled()) logger.LogWarning("Did not find target for destroy message for " + netId);
|
if (logger.LogEnabled()) logger.LogWarning("Did not find target for destroy message for " + netId);
|
||||||
|
Loading…
Reference in New Issue
Block a user