Announcement

Collapse
No announcement yet.

Reflection system and sub-macro

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Reflection system and sub-macro

    Hey guys. Started messing up with abilities system and got an idea to define attributes with initter, getter, setter, delegate, etc. in one line. Like this:
    Definition:
    Code:
    #define LAZY_ATTRIBUTE(ClassName, PropertyName, DispatcherSig) \
        UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Cool") \
        FGameplayAttributeData PropertyName; \
        \
        GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
        GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
        GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
        GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName) \
        \
        UPROPERTY(VisibleAnywhere, BlueprintAssignable) \
        DispatcherSig On##PropertyName##Changed;
    Use:
    Code:
    LAZY_ATTRIBUTE(UMyAttributeSet, Health2, FPropertyChanged)
    Though it works perfectly in C++, it doesn't expose UPROPERTies to blueprints. I believe it is because of reflection system doesn't "see" those sub-macros. Is it possible to fix somehow except moving UPROPERTY out of the macro? Thanks in advance.

    #2
    Correct, UHT will not parse those macros inside macros. There is nothing you can do about it unfortunately.

    Comment


      #3
      The problem is Epic's compiler cannot identify "PropertyName". You have to manually define it, cannot be a macro dynamic.
      | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

      Comment


        #4
        So sad. But thanks for reply!

        Comment

        Working...
        X