How to declare the same types of variables in one line?

I want to shorten this, as logically you can see I should be able to declare the variables as:
I hope this is possible…

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskHands, MaskShirt, MaskJacket ;

and NOT like this:

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskHands;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskShirt;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskJacket;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskVest;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskPants;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskShoes;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskWhole;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Mask Fashion Items Related)
class UTexture* MaskBody;

as each variable needs the UPROPERTY macro, I think you just can’t define in the same line.

1 Like

but they should take the property from one line too, as you can see the property derive the the base class type class UTexture and than UTexture is deriving the variables… they should automatically clone the base properties from UTexture

@eldany.uy is right. With UPROPERTY(), each variable should be declared separately. However, you only need class once with the first one.
Or you can make it an array.

1 Like

I’m pretty sure it’s not possible, since I’ve never seen it before. Why do you want to do it? Just to save space? Consider using a Struct or TMap instead. Having a TMap with an Enum as the key and UTexture* as the value is the best way I can think of.

1 Like

Yes Now I am using them under struct.

Please use Unreal style guide by Allar, it makes it easier for other people to read your code.

1 Like

nice Information, but still he need to cover dynamic delegates.

nice information, but I am working with Structs and later will learn about TMap obviously

Others already explained that, while the C++ compiler allows you to declare multiple variables on the same line, the Unreal Header Tool does not. Thus, for Unreal properties, you cannot declare more than one thing on the same line.

However, what I want to call out, is that this particular declaration doesn’t do what you say it would do. It declares point pointer to a UTexture, called MaskHands, and then two UTexture direct class instances, named MaskShirt and MaskJacket. So, even if the properties could be shared by multiple variables (which they can’t,) the code you posted wouldn’t work.

1 Like

All clear, thank you for the detailed information.

I knew something drove me nuts about the modern tendency to put the * at the end of the type, versus at the beginning of the name.

If anyone needs an explanation, the * pointer symbol groups to the name of the item, rather than the type of the item. *MaskHands is a pointer, MaskShirt is an instance.

instance of MaskHands?