x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Safely find a reflected property name?

Hi all...

I need to access a UPROPERTY of a UCLASS through reflection in C++. It shouldn't present any challenge in itself, something along the lines of:

 MyObject->GetClass()->FindPropertyByName(TEXT("MyPropertyName"));

However I'm absolutely certain that there's a preprocessor macro that provides safe way to reference a property name in C++, that will throw a compile time error in the event that the name changes. Something like this:

 FName PropertyName = MAGIC_PROPERTY_MACRO(MyClass::StaticClass(), TEXT("PropertyName"));
 Settings->GetClass()->FindPropertyByName(PropertyName);

Can anyone remember what this macro's called? It's a bit tricky to find-in-all-files within the source code as I just can't remember any part of its name! (Tried searching for safe property, things like that - also tried googling for half an hour). Gone through UClass.h to no avail.

Product Version: UE 4.20
Tags:
more ▼

asked Feb 02 '19 at 06:16 PM in C++ Programming

avatar image

DerPurpelHelmut
531 8 12 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Ah found it... GET_MEMBER_NAME_STRING_CHECKED.

 UProperty* Property = UStaticMesh::StaticClass()->FindPropertyByName(GET_MEMBER_NAME_STRING_CHECKED(UStaticMesh, SectionInfoMap));

For anyone else reading this in the future, there's also GET_FUNCTION_NAME_CHECKED.

more ▼

answered Feb 02 '19 at 06:46 PM

avatar image

DerPurpelHelmut
531 8 12 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question