Hi could anyone please paste a code example on how to do for loop for TArray<TSubclassOf> WhateverArray; Thanks
for (TSubclassOf Whatever : WhateverArray)
{ //this won’t compile and I can’t find solution online
}
Hey @Kontikiki, here’s what I’ve made:
TArray MyArray;
MyArray.Reserve(MyArray.Num());
for (int i = 0; i < MyArray.Num(); ++i) {
// Extract item from the array
ExampleClass MyItem = MyArray[i];
}
I hope this can help!
-Zen
You have to match the entirety of the template parameter. So given:
TArray< TSubclassOf<UClass> > WhateverArray
The ranged for-loop would be:
for (TSubclassOf< UClass > Whatever : WhateverArray)
or
for (const TSubclassOf< UClass > &Whatever : WhateverArray)
or even
for (const auto &Whatever : WhateverArray)
You could also do a more classic int i = 0
form that ZenLeviathan demonstrated.
OK guys thanks I made actually a typo error of small i instead of capital I. It’s UAISense not UAiSense. I can see it now when posting it on forum. Thank you both for your response.