Coming from a Unity background, you can have private variables in a class but by assigning various properties like [SerializedField] or [Multiline] we can modify them in the inspector in some way (see post here). The Unreal Engine has a similar method that uses the UPROPERTY() macro, which can be used to do similar things.
For example, the UPROPERTY(VisibleAnywhere) allows the variable to show up in the inspector but is not modifiable, whereas the UPROPERTY(EditAnywhere) allows the variable to be visible in the inspector but also can be modified.
To use the UPROPERTY() macro in a class you must use the macro above the variable in question and make sure that there are no white spaces between UPROPERTY and the brackets. An Example is below.
class SomeClass
{
public:
SomeClass();
private:
UPROPERTY(EditAnywhere)
FRotator openRotation = FRotator(0.f, 90.f, 0.f);
}
There is more detail on each of the specifiers which can be found here.
No comments:
Post a Comment