mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
perf: InterestManagement update time is now set in RebuildAll instead of Update. Avoids unnecessary updates if someone just called RebuildAll anyway
This commit is contained in:
parent
2c41dc0ae5
commit
294c267472
@ -111,19 +111,22 @@ public void RebuildAll()
|
|||||||
RebuildObservers();
|
RebuildObservers();
|
||||||
RemoveOldObservers();
|
RemoveOldObservers();
|
||||||
AddNewObservers();
|
AddNewObservers();
|
||||||
|
|
||||||
|
// RebuildAll can be called from the outside, so we should set the
|
||||||
|
// lastUpdateTime in here instead of in Update.
|
||||||
|
// this way we avoid updating if someone from the outside recently
|
||||||
|
// did a rebuild anyway (e.g. in OnServerDisconnect).
|
||||||
|
lastUpdateTime = Time.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update rebuilds every couple of seconds
|
// update rebuilds every couple of seconds
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
// only while server is running
|
// only while server is running
|
||||||
if (NetworkServer.active)
|
if (NetworkServer.active &&
|
||||||
{
|
Time.time >= lastUpdateTime + updateInterval)
|
||||||
if (Time.time >= lastUpdateTime + updateInterval)
|
|
||||||
{
|
{
|
||||||
RebuildAll();
|
RebuildAll();
|
||||||
lastUpdateTime = Time.time;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user