C++ Const Correct Functions do not show in Blueprint

I have discovered that functions with const postfixes are not liked by the blueprint system.

I have a function declared:

UClass(blueprintable)
class UMyObject : UObject
{
    UFUNCTION(BlueprintCallable, Category="My Category")
    int32 GetMyValueFromIndex(const int32 index) const
}

The function will not display in the blueprint until I remove the “const” from the function ending.

UClass(blueprintable)
class UMyObject : UObject
{
    UFUNCTION(BlueprintCallable, Category="My Category")
    int32 GetMyValueFromIndex(const int32 index)
}

It’s a minor bug but one that urks the C++ guru in my heart.

Try marking the function as BlueprintPure instead of just BlueprintCallable.

A little more information can be found here, but I am not at a machine with a build handy at present so I can’t check if it is up-to-date.

Actually, “BlueprintCallable” and “const” at the end should be enough and do the job for me. The problem must be somewhere else.

Dumb question, but when you’re trying to add the function call to blueprint, are you dragging from Exec connector? Blueprint pure (or const) functions are not shown in executable actions, so maybe this is your “problem” :wink:

You’ll have to pardon my lack of technical understanding of the blueprint system, but if I am following what you asked I think the answer is… not exactly… maybe? haha.

If you are referring to the big white arrow on the blueprint nodes, then no not really. I have tried directly right clicking in a blank space and going straight to the functions I need but when I open the category only 2 out of the 5 or so functions I created are there. When I remove the const at the end of that function, it then appears in the function listing.

If you are refering to a return type (or if EXEC connector refers to both a return type and the big white arrow) then the answer is yes. I tried pulling some functions from another object that also had functions ending with const to find it too was missing functions, which lead me down this rabbit hole until I figured it out :slight_smile:

Okay so if I am reading that correctly marking a function as BlueprintPure is equivalent to marking it with the const function at the end… I think I can live with that but I still wonder if the final compiled code is optimized as const… (it’s really just a curiosity and partly OCD…) I must say though that the Property and Function specifier documentation can be a bit cryptic as a few of them I have only figured out through other people’s tutorials. I hope that gets evaluated on the next pass of the documentation :slight_smile: