In this lesson, you will learn how to create dynamic, data-driven dropdown menus in the Unreal Editor by combining meta specifiers with custom property accessors.
Why Use Dynamic Dropdowns?
Hardcoding values for designers is error-prone. Instead of asking a designer to type a string name for a "Target Socket" or "Ability ID," you can use the GetOptions metadata. This allows the Unreal Editor to call a specific function in your C++ class to populate a list of available options dynamically.
Implementing the Logic
To enable this, you need two pieces: a UFUNCTION that returns an array of strings, and a UPROPERTY that points to that function via the GetOptions metadata.
First, define your function (it must return TArray<FString> and be marked as BlueprintCallable or CallInEditor):
UFUNCTION()
TArray<FString> GetAvailableTargetOptions() const
{
// In a real scenario, you might scan your map keys or look up data assets
return { "Head", "Chest", "Feet" };
}
Next, link this function to your property using the meta=(GetOptions="FunctionName") specifier:
UPROPERTY(EditAnywhere, meta=(GetOptions="GetAvailableTargetOptions"))
FString TargetSocketName;
How it Works
When you compile your code, the Unreal Editor’s Property Inspector looks for the function named GetAvailableTargetOptions. Every time you click on that property in the editor, the engine executes your C++ function and displays the returned TArray as a neat, selectable dropdown menu.
This keeps your code flexible—if your data source changes (e.g., you add new sockets to a character model), the dropdown will automatically reflect those changes the next time the inspector is refreshed. This is significantly safer than relying on manual string inputs, which often lead to typos and broken references during gameplay.
Key Takeaway: Use meta=(GetOptions="FunctionName") to transform simple string properties into dynamic, designer-friendly dropdown menus that automatically sync with your C++ data logic.