How do I get the current AspectRatio of a camera from within C++?
For some reason, the UCameraComponent::AspectRatio
member is private, and there is no getter available.
The member has, however, the BlueprintReadWrite
property. Since I need the AspectRatio in a base class (there are other C++ classes inheriting from it), I can’t simply inherit a Blueprint and create a getter there.
Since the AspectRatio is private (not protected), I am also not able to inherit from UCameraComponent
and create a getter there…
I tested and it works for me, if you relete on auto complete or some auto error markings just ignore them they probably fulled by fact that GENERATED_UCLASS_BODY() hides “public:”. My CodeLite also shows AspectRatio as private but it normally builds
This is known issue and so new macro set up (GENERATED_BODY()) don’t apply “public:” automatically and force developer to place it by themselves as C++ standards expect. But still there lot of code in engine that use old set up so it will take some time every class get fixed.
Wow, that was … unexpected. You are right, the AspectRatio is in fact public. But since the public:
was inside the macro, I didn’t see it. Seems that compiling is often the only way to find out if something works. But this definitly safes me a lot of work