What is the "Add Unique" array node in 4.6?

How, I was searching for a “Set” container functionality but no Set in UE4 Blueprint. Mayve this is the current way to add unique objects in Array?

1 Like

Just saw this in the context menu. Don’t know when it got added, could have been 4.5 for all I know.

Anyway, what does it do? It doesn’t exactly have a useful tooltip…

it appends an element at the end of an array, if the element is not already present.

addUnique() does an array.find(), and if it doesn’t find any copies of the value you are trying to add, it adds the element to the end of the array.

3 Likes

So, it’s a kind of Set functionality in an Array Container.
Though, it was better to expose the TSet Container to take advantage of Hashing mechanism and related performance gains.

That said, good to know that we can play with Arrays of uniques items.

Great, thanks for the explanation!

Just for clarification. If I want my array to contain multiple of the EXACT same object (at different indexes) I just need to use the ‘Add’ node?

Yes, you have to use the ‘Add’ node, because the ‘Add unique’ node is made to avoid such things.

1 Like