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"

C++ Access To Variables Using Reflection

I am trying to access the UProperties of Blueprints using reflection. I can access them, it appears, if the property is a class, but not a simple variable type (bool/int/struct, etc.). For example, if I create a Blueprint and add a Dynamic Material Instance property, it shows up in the list of properties for the class. However, if I create a simple LinearColor or float as a variable on the Blueprint, it doesn't show up. How to access these variables using reflection?


Product Version: UE 4.8
more ▼

asked Jun 12 '15 at 08:07 PM in C++ Programming

avatar image

46 7 13 17

avatar image Embeddetech Jun 12 '15 at 08:09 PM

This is all in C++, by the way, I need to be able to enumerate the variables of a Blueprint in C++ using reflection, including simple variable types.

avatar image Zaucy Jun 12 '15 at 09:56 PM

I haven't looked into it, but are your properties on your blueprint public? That might affect your ability to see them through UProperty.

Another thing I might try is to try casting your UProperty into a UNumericProperty and see if it's valid. And for the LinearColor try casting to UStructProperty. There's also a UBoolProperty for bools.

I'm sure there's a more elegant solution than to try casting and seeing if they are valid, but I thought I'd give you some things to try.

avatar image Embeddetech Jun 15 '15 at 08:24 PM

Hi Zaucy, Thanks for the response! I believe the initial problem I am having is getting a reference to the property, currently I am taking an object, getting its StaticClass(), and then enumerating through the static class PropertyLink linked list. I can get the name of each property on this list, and the LinearColor and other primitives don't show up in this list. Just objects like DynamicMaterialInstance variables or StaticMesh components.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hi Embeddetech,

When accessing a variable that has been created in the blueprint editor in C++, you'll need to access them by the name of the UProperty, and then use ContainerPtrToValuePtr to do anything with them. You can find more information about ContainerPtrToValuePtr here:


Hope this helps!

Matthew Clark

more ▼

answered Jun 15 '15 at 04:56 PM

avatar image

Matthew J ♦♦ STAFF
31.8k 526 91 417

avatar image Embeddetech Jun 15 '15 at 08:22 PM

Hi Matthew, Thanks for the support! I in general won't know what the name of the property is, and am trying to use the reflection system to generalize the solution (I've verified that this is indeed what I need, not a kludgy way of doing what I'm needing to do). So what I am currently doing is getting an object's StaticClass, then getting its PropertyLink, and iterating through the PropertyLink linked list I can get the name of the field using the PropertyLink->GetName() function. However when I use this approach, my structs and primitive elements (floats, ints, etc.) don't show up. Is there another way to find these properties?

Also, if I were to access them by the name of the UProperty, what's the right way to do that?


avatar image Matthew J ♦♦ STAFF Jun 15 '15 at 08:57 PM

I believe, trying to do what you're trying to do, it would be much easier and much less of a hassle if you were to declare these UProperties in the C++ class that these blueprints are based off of instead of trying to refer to variables that have been created inside of the blueprints themselves. This would allow for much more versatility and less overhead overall.

If you do wish to stick to this method however, you should be able to find the name by using a pointer to a UProperty and using FindPropertyByName.


avatar image Embeddetech Jul 03 '15 at 04:06 AM

Hi Matthew, I was able to get at, there were a couple of things I was doing wrong. First, I wasn't using the TFieldIterator class, when I went to that I was able to get all of my fields. After that, I was able to use the UProperty's GetCPPType reflection capabilities to at least get the name of the property's type. I think that should be good enough for my purposes.

Thanks again!

(comments are locked)
10|2000 characters needed characters left
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