Download

Help to made BP node to select Class and VarsCategory from DropDown lists, and return Vars Array.

Hi, target is Widget Blueprint. In Designer i mark elements to Var, but in Graph is needed import each var individualy to made array. When the UI is big, is a waste of time, a excesive Graph size, and more difficult maintenance when modify UI. Need a way to import the array of selected category. I consider this a basic task, sadly not available. Moreover with this node, you can add and delete vars in this category, and automaticaly array is updated after compile, saving your time and avoiding mistakes in this management. Is nonsense, Graph let us specify category in Details tab, but none way to call this category :rolleyes:

The idea is get code from “Construc Object from Class” node, at UE_4.24\Engine\Source\Editor\BlueprintGraph\Classes\K2Node_ConstructObjectFromClass.h and …\BlueprintGraph\private\K2Node_ConstructObjectFromClass.cpp, and made a C++ class in my project. Adding DropDownList for select Variable Category, changing return to array, and delete the rest of code.

I have created the C++ class, copy/paste code from original files, modify include, class declaration. Now target is delete all code in .h class declaration except the necessary to maintain the Class DropDownList selection. I’ve read the code but i’m stucked, i’m beginner in C++

After this, i will search how call category and return array, that sound easy task.

Thanks !

I’m not 100% certain on what it is you want to do. Am I correct in saying you essentially want to have a custom Blueprint node, such that when you pass in your selected category, the node returns an Array associated with that class type. And then are you wanting to just simply have a dropdown on the node which allows you to select a category, or are you wanting to pass the category in as an object? Sorry if I’ve misunderstood. However I believe you can use an Enum for this sort of thing.



/** We use an Enum to represent the different Categories that we want to have in our DropDown */
UENUM(BlueprintType)
enum class EMyEnum : uint8
{
    MyFirstCategory UMETA(DisplayName = "MyFirstCategory"), // We set the DisplayName with the UMETA macro.
    MySecondCategory UMETA(DisplayName = "MySecondCategory"),
    MyThirdCategory UMETA(DisplayName = "MyThirdCategory"),

    ...
};

/** This is our UFUNCTION() which will have a dropdown on it, and then return the appropriate array.
  *  To display the Enum as a drop down we use TEnumAsByte<EMyEnum>*/
TArray<MyArrayDataType> UMyClass::GetCategoryData(const TEnumAsByte<EMyEnum>& Category)
{
    /** Use a switch statement to return the array from the selected category */
    switch(Category)
        case EMyEnum::MyFirstCategory:
            return MyFirstCategoryObject->MyFirstCategoryArray;
        case EMyEnum::MySecondCategory:
            return MySecondCategoryObject->MySecondCategoryArray;
        case EMyEnum::MyThirdCategory:
            return MyThirdCategoryObject->MyThirdCategoryArray;

    ...
}


Hope this is of some use to you.

Thanks, this solve part of the original goal.

Now i’m trying to do a more small node to get the array, my first post is not well focused, is much more difficult than what is realy needed.

Now the “class to class object reference” is done with the native node “Construct Object from Class”, and connect “class object reference out pin” to “class object reference in pin” of our node.

Also change “UEnum DropDownList” of variable categories, to just “String entry pin” for type the target variable category name.

I need help to create the “class object reference entry pin”, is possible to do it from user project ? I prefer not edit UE4 code, unless is absolutely necessary, to make upgrades to new UE versions more easy, thanks.

Is possible iterate from C++ over a Blueprint Class to find all variables of the same category ? UE Property System (Reflection) allow this ? Thanks

Property category is part of editor-only meta data, what you want won’t work for a packaged build.

If Blueprint is nativized during packaging, change somethig ?

There are any Blueprint Graph node to iterate over class to get property meta data ? I’ve searched but not find it. Thanks !