Hi, I have a function that is invoked by UI click, which modifies a TArray, and in Tick, it does that too.
Pseduo code
TArray <UUserWidget *> pool;
TArray <UUserWidget *> active;
UFUNCTION (BlueprintCallable)
void FunctionFromUIClick ()
{
if (! pool.IsEmpty ())
{
UUserWidget *> u = pool.Pop ();
active.Add ();
}
}
void Tick (float deltaTime) override
{
TArray <UUserWidget *> temp;
for (UUserWidget * u: active)
if (! u.IsInViewport ())
temp.Add (u)
for (UUserWidget * t : temp)
{
active.Remove (t);
pool.Add (t);
}
}
Sometime, it will crash when I spam click FunctionFromUIClick from blueprint. It seems like a race condition, the blueprint Click is not in same game thread as Tick?