How to set a UFUNCTION parameter's default value to a defined variable?

I’d like to be able to set the Table parameter’s default value to be whatever the assigned value of DataTableRef is. Is this possible using UFUNCTION specifiers?

(UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UDataTable* DataTableRef;

// set Table default value as DataTableRef?
UFUNCTION(BlueprintCallable, meta = (DataTablePin = Table))
void TestFunc(UDataTable* Table, FName RowName);

I don’t think it’s possible. What you could do is default to DataTableRef if Table is null.

UDataTable* DT = Table ? Table : DataTableRef;
1 Like

I mainly just wanted to be able to set it whenever the node is created in the editor – not at runtime – this way you wouldn’t have to set the proper data table each time you create the node.
If its not possible though, I can find another way. Thanks for your response!

I will confirm (so stronger language) that what you are asking is not possible. You can only provide function defaults that are known at compile time.

3 Likes

UFUNCTION(BlueprintCallable, meta = (DisplayName = “ReadDatabase”, Keywords = “Local Database”, Columns = “*”, Where = “NULL”), Category = “SQLiteLocalDatabase”)
static void Read(FString TableName,FString Columns, FString Where, TArray& myDataStruct);

Look in Meta Columns and Where Default.
its worked for me. UE5.03

1 Like

Yeah it’s confusing. “Runtime” is used in two different senses. It can mean (a) when the game is running (under a UGameInstance) but not when the editor is running, or (b) more generally, when a program is running which includes a game or an editor.

(a) would probably be better described as “in-game” or “during play” to disambiguate.

(b) is used to distinguish runtime from compiletime, as in when you are compiling the program (ie Build Project in Visual Studio).

(b) is the sense we use when talking about C++ language rules.