Announcement

Collapse
No announcement yet.

[Feature] Ability to modify how a C++ BlueprintCallable function is generated in BP.

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

    [Feature] Ability to modify how a C++ BlueprintCallable function is generated in BP.

    I have an interface defined in C++. The interface is implemented by Blueprint Actors. I use the interface by calling the interface functions from a C++ class, and the interface calls are received by the blueprint actors.

    However, it seems to be currently impossible to create default implementations for interface functions which are blueprintcallable. The only workaround for this is to make a BlueprintCallable, BlueprintNativeEvent in the interface, and then make a new C++ base class for the receiving blueprint actors where the Function_Implementation is created. Doing it this way, however, largely destroys the purpose of using interfaces in the first place, especially with blueprints, as they don't support multiple inheritance in the same way C++ does.

    When the interface function is created in blueprint it will, by default, just have an execution wire and some return value. There are some functions in my interface where I use the functions to simply check a flag, which by 90% of the cases is set to a certain value, and then proceed from there. However, the slight issue I have is that the default values for these flags will be set to however the blueprint functions are generated.

    Booleans will automatically be false, structs will always default to the first value. So now to generate a flag you may have to modify a boolean in a manner such as "bIsNOTDoingSomething" or reorder your struct to fit with the default return value. Alternatively, you could use the most sensible boolean names or struct orders, but then you'd have to make changes to the functions in all actors that end up implementing the interface.

    I guess that interface functions in blueprints cannot have default implementations for a good reason, but there could be a way to manipulate the default return value of the generated function in some way. Such as
    Code:
    UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, meta=(BlueprintDefaultReturn = true))
    bool ExampleFunction();
    or
    Code:
    UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, meta=(BlueprintDefaultReturn = SomeStruct::SecondValue))
    SomeStruct ExampleFunction2();
Working...
X