Announcement

Collapse
No announcement yet.

UPROPERTY variables in a standard struct

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

    UPROPERTY variables in a standard struct

    Will the UPROPERTY TArray below prevent garbage collection of its elements? Or do I need a USTRUCT() for UPROPERTY members to work correctly?

    The problem with USTRUCT() is that I cannot create them with template parameters.

    Code:
    template<typename T>
    struct FMenuItemList
    {
        UPROPERTY(VisibleAnywhere, Category = "Menu")
        TArray<T> ItemList;
    
        int32 CurrentItem;
    };
    Last edited by Curious_Rubick; 06-11-2016, 11:23 AM.

    #2
    Nope, won't work, your struct needs to itself be a UPROPERTY, directly or indirectly, of a UCLASS, since only UObjects are tracked by the reference collector.

    Bottom line is, you just can't mix templates with UE4's reflection system.

    Comment

    Working...
    X