UMG When I try the more convenient binding property

My design is to allow a UMG to set an ObjectClass, and then bind to the properties of this Object in UMG. But I must use UObject in Cpp to hold any subclasses

https://preview.redd.it/j2xs9k060o4f1.png?width=841&format=png&auto=webp&s=2867cf8f82ea8f73001360d3abe67109822413ec

At this time, even if Object is a subclass, the editor will treat it as Object. After reading the relevant source code, I determined that the editor only relies on the FObjectProperty->PropertyClass corresponding to the Object to determine the class of the Object, so I wrote the following code.

https://preview.redd.it/7ft3s9590o4f1.png?width=737&format=png&auto=webp&s=69c89ea4e531b47b7ffcc0104480f7b370869233

I made sure that the class of Object was indeed ObjectClass, otherwise there would be a fatal error, so I got the following effect, and everything worked fine when it was running.

https://preview.redd.it/z4uvx40h0o4f1.png?width=496&format=png&auto=webp&s=86082778d193a37783d865bc782c6f2cbd1b376f

Although this is really convenient, my approach is still dangerous. If this result is good, we should support this function in the source code.

Posted Jun 3, 2025, 7:35 AM UTC

10
Loading comments…