MajekPL
(MajekPL)
February 1, 2016, 1:41pm
1
hey.
in my header its
UPROPERTY(BlueprintReadWrite, Category = “Config”)
TArray<uint8>ArrayName;
im using this in my constructor: ArrayName.Add = (8, -8, 1, -1, 7, -7, 9, -9);
but he returns an error: “=”: function as left operant.
whats wrong?
thanks!
amcgator
(amcgator)
February 1, 2016, 4:13pm
2
I think you can only add one item at a time so in your case it would be
ArrayName.Add(8);
ArrayName.Add(-8);
ArrayName.Add(1)
ArrayName.Add(-1)
ZkarmaKun
(ZkarmaKun)
February 2, 2016, 1:21am
3
hi majekpl maybe you must see basics of programming .Add is a method inside TArray for abvious reason cant be assigned
.Add is using like this myArray.Add(myobj) all method need some arguments if required check about object oriented programming and how to do a class from scratch
if you want use tarray costructor you need use like this myArray.Init()
Jackblue
(Jackblue)
February 2, 2016, 8:40am
4
You can read some useful things about TArray here:
After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...
Reading time: 1 mins 🕑
Likes: 8 ❤
If you want to populate an Array in one line, you can do this:
TArray<uint8> ArrayName;
uint8 SimpleArray] = {8, -8, 1, -1, 7, -7, 9, -9};
ArrayName.Append(SimpleArray, ARRAY_COUNT(SimpleArray));
I hope this help you
1 Like