Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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).
// 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
You can’t perform that action at this time.