Skip to content

Instantly share code, notes, and snippets.

@trentpolack
Last active January 26, 2018 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trentpolack/a1bdcd3002d0eda2bf17a46b5c292bf7 to your computer and use it in GitHub Desktop.
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).
// 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