Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Assets/uPools/Runtime/Internal/PoolCallbackHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ internal static class PoolCallbackHelper
public static void InvokeOnRent(GameObject obj)
{
obj.GetComponentsInChildren(componentsBuffer);
foreach (var receiver in componentsBuffer)
var componentsToInvoke = new List<IPoolCallbackReceiver>(componentsBuffer);

foreach (var receiver in componentsToInvoke)
{
receiver.OnRent();
}
Expand All @@ -19,10 +21,12 @@ public static void InvokeOnRent(GameObject obj)
public static void InvokeOnReturn(GameObject obj)
{
obj.GetComponentsInChildren(componentsBuffer);
foreach (var receiver in componentsBuffer)
var componentsToInvoke = new List<IPoolCallbackReceiver>(componentsBuffer);

foreach (var receiver in componentsToInvoke)
{
receiver.OnReturn();
}
}
}
}
}