Some new Blueprint Macros (Updated StandardMacros)

Hello guys,

After working with UE4 editor, I’ve noticed the lack of some useful macros, and by macros I mean the standard ones like forloop, foreachloop … So, I’ve created a Macro library with :

  • ForLoopWithIncrement and ForLoopWithBreakAndIncrement (with “IncrementBy” integer)
  • ForLoopExclusive and ForLoopExclusiveWithBreak
  • ForLoopReverse and ForLoopReverseWithBreak (with “DecrementBy” integer)
  • ForLoopReverseExclusive and ForLoopReverseExclusiveWithBreak

The link


Sorry i’m confused, the for and foreach are already part of the standard macro library along with many others.

Don’t be, I’ll try to explain with a simple example :

  • **ForLoop **and **ForLoopWithBreak **of UE4 => default forloop behavior, but incluvise, it increments each time the counter by 1 => for (int i = lowerValue, i <= higherValue, i++)
  • ForLoopWithIncrementand **ForLoopWithBreakAndIncrement ** of the CommonMacros library => inclusive too, you can increment by whichever integer value, you can get elements 2 by 2 or 3 by 3 and so on => for (int i = lowerValue, i <= higherValue, i += incrementBy)
  • ForLoopExclusiveand ForLoopExclusiveWithBreak of the CommonMacros library => this is the default forloop behavior for whomever used C-style languages and others as well, it increments by 1 and is exclusive => for (int i = lowerValue, i < higherValue, i ++)
  • ForLoopReverseand ForLoopReverseWithBreak of the CommonMacros library=> browse inversely, from a higher value to a lower value, a DecrementBy integer is added to customize the loop => for (int i = HigherValue, i >= lowerValue, i -= decrementBy)
  • ForLoopReverseExclusiveand ForLoopReverseExclusiveWithBreak of the CommonMacros library=> browse inversely, from a higher value to a lower value, a DecrementBy integer is added to customize the loop, and it is exclusive => for (int i = HigherValue, i > lowerValue, i -= decrementBy)

Again, the …Break macros introduce the same break behavior of the standard ForLoopWithBreak, ForEachLoopWithBreak, WhileLoop …

I hope I’ve clarified the “why I’ve added a CommomMacros library”.


That’s clarified it thank you, I misinterpreted (or didn’t read correctly) the for loop with integer.

Nice work creating these!

Nice! Any chance these get added to the core UE4 build?

Thanks for these!!

how do I load them into my project?

Thanks! I’m sure I’ll have use of these at one point.

While these are nice macros, but I would oppose that part. These kind of macros, are actually much less used generally speaking, but I think adding them to the official macros, makes most of the newer users quite confused, it essentially causes more problems that would solve. Using them as a add on macro base, would be the best solution, which means only the users that feel confident enough will integrate and use them.

Hey guys,

Thanks for the comments!

@Venged Just add this file to your project hierarchy (e.g. Create a new folder in your project then copy this file in it, it should be loaded automatically)

@Farshad12 I think those macros should have been within UE4 from the beginning, I find myself confused when I always had to get my array length and do a -1 before setting that to the forloop… Again, giving choices for exclusive/inclusive should have been a boolean, same thing for the IncrementBy and DecrementBy integer, they should have been added as parameters

Re: the array length - 1 thing, when you pull off of an array, there should also be an option called “Last Index” that effectively will do that for you as a convenience.