mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: #3392 NetworkLoop now checks if the function was already added before. fixes functions being added twice with Domain Reload disabled.
This commit is contained in:
parent
91014bd614
commit
8f66bd68ca
@ -99,6 +99,15 @@ internal static bool AddToPlayerLoop(PlayerLoopSystem.UpdateFunction function, T
|
|||||||
//foreach (PlayerLoopSystem sys in playerLoop.subSystemList)
|
//foreach (PlayerLoopSystem sys in playerLoop.subSystemList)
|
||||||
// Debug.Log($" ->{sys.type}");
|
// Debug.Log($" ->{sys.type}");
|
||||||
|
|
||||||
|
// make sure the function wasn't added yet.
|
||||||
|
// with domain reload disabled, it would otherwise be added twice:
|
||||||
|
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3392
|
||||||
|
if (Array.FindIndex(playerLoop.subSystemList, (s => s.updateDelegate == function)) != -1)
|
||||||
|
{
|
||||||
|
// loop contains the function, so return true.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// resize & expand subSystemList to fit one more entry
|
// resize & expand subSystemList to fit one more entry
|
||||||
int oldListLength = (playerLoop.subSystemList != null) ? playerLoop.subSystemList.Length : 0;
|
int oldListLength = (playerLoop.subSystemList != null) ? playerLoop.subSystemList.Length : 0;
|
||||||
Array.Resize(ref playerLoop.subSystemList, oldListLength + 1);
|
Array.Resize(ref playerLoop.subSystemList, oldListLength + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user