Last active
January 26, 2018 19:48
-
-
Save trentpolack/a1bdcd3002d0eda2bf17a46b5c292bf7 to your computer and use it in GitHub Desktop.
Unreal Engine 4 -- Member Accessor Method Macros (NOTE: This does not result in the accessors being available for blueprint-use as they're not UFUNCTIONs).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: This does not result in the accessors being available for blueprint-use as they're not UFUNCTIONs. | |
UCLASS( ) | |
class URawr : public UObject | |
{ | |
GENERATED_CLASS( ) | |
protected: | |
float RawrValue; | |
public: | |
#define DEFINE_METHOD_SET_ACCESSOR( MemberType, Member ) \ | |
FORCEINLINE_DEBUGGABLE void Set##Member( MemberType Member##In ) \ | |
{ \ | |
Member = Member##In; \ | |
} | |
#define DEFINE_METHOD_GET_ACCESSOR( MemberType, Member ) \ | |
FORCEINLINE_DEBUGGABLE MemberType Get##Member( ) const \ | |
{ \ | |
return Member; \ | |
} | |
#define DEFINE_METHOD_ACCESSORS( MemberType, Member ) \ | |
DEFINE_METHOD_SET_ACCESSOR( MemberType, Member ) \ | |
DEFINE_METHOD_GET_ACCESSOR( MemberType, Member ) | |
// Define set/get accessors for RawrValue. | |
DEFINE_METHOD_ACCESSORS( float, RawrValue ) | |
#undef DEFINE_METHOD_ACCESSORS | |
#undef DEFINE_METHOD_GET_ACCESSOR | |
#undef DEFINE_METHOD_SET_ACCESSOR | |
}; | |
// Now actual things: | |
RawrInstance->SetRawrValue( 7777 ); | |
uint32 rawr = RawrInstance->GetRawrValue( ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment