Announcement

Collapse
No announcement yet.

How to use UFUNCTION macro with inline methods?

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

  • replied
    It may be a bug, but the solution is simple. Just remove the 'inline', and write the definition to the header. All definitions in a header will be treated as inline function.
    class UAxx
    {
    GENERATED_BODY()
    public:
    UFUNCTION(BlueprintCallable)
    void Hello(){printf("xxx");};
    }

    Leave a comment:


  • replied
    Definitely possible yeah.

    Leave a comment:


  • replied
    is it possible to create a #define macro to create blueprint callable functions?

    Leave a comment:


  • replied
    for BlueprintNativeEvents use this syntax:

    Code:

    UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "local") FORCEINLINE
    USoundCue* getEmptyChamberSound();
    USoundCue* getEmptyChamberSound_Implementation(){return nullptr;};


    thank me later
    Last edited by Arty-McLabin; 02-06-2018, 09:28 AM.

    Leave a comment:


  • replied
    Originally posted by kamrann View Post
    It's probably just a limitation of UHT (it has many).

    It's completely unnecessary though, inline or not is totally insignificant in comparison to the overhead of calling a function from blueprint. If you need to call this function from C++ a lot, then make an inline function to do the work, and then a separate BlueprintCallable UFUNCTION that just calls the inline function.

    If you're going to be calling the function so often from blueprint that you're worrying about inlining it though, then you just shouldn't be calling it from blueprint in the first place.
    Seems to be a wise summary, thanks a lot!

    Leave a comment:


  • replied
    It's probably just a limitation of UHT (it has many).

    It's completely unnecessary though, inline or not is totally insignificant in comparison to the overhead of calling a function from blueprint. If you need to call this function from C++ a lot, then make an inline function to do the work, and then a separate BlueprintCallable UFUNCTION that just calls the inline function.

    If you're going to be calling the function so often from blueprint that you're worrying about inlining it though, then you just shouldn't be calling it from blueprint in the first place.

    Leave a comment:


  • replied
    Well, whether or not a function or method in C++ should or should not be inlined is a broad topic, which I don't want to discuss here. My question was more if it is possible in UE4 to have an inlined UFUNCTION

    Leave a comment:


  • replied
    Why do you want it to be inlined?

    I would suggest getting the function to show up in BP before (trying) to get it inlined.

    HTH

    Leave a comment:


  • replied
    Originally posted by ryan20fun View Post
    Have you tried moving the implementation to the .cpp file or to the end of the header?
    Sure, that would work.
    But my intention was to compile this method inline ...

    Leave a comment:


  • replied
    My game mode class starts like this:
    Code:
    UCLASS(minimalapi)
    class AGDemoGameMode : public AGameMode
    {
    	GENERATED_BODY()
    Have you tried moving the implementation to the .cpp file or to the end of the header?

    HTH

    Leave a comment:


  • started a topic How to use UFUNCTION macro with inline methods?

    How to use UFUNCTION macro with inline methods?

    I have the following method in my game mode class (header file):

    Code:
    void BadBugDied(APawn* BadBug) { BadBugs.Remove(BadBug); }
    This compiles and works fine.
    Now I add the UFUNCTION macro, to call this method from BP:

    Code:
    UFUNCTION(BlueprintCallable, Category = "Bad Bugs")
    FORCEINLINE void BadBugDied(APawn* BadBug) { BadBugs.Remove(BadBug); }
    This leads to the following error during compilation:

    "Unrecognized type 'void' - type must be a UCLASS, USTRUCT or UENUM"

    The same error occurs also when I use the inline keyword instead of the FORCEINLINE macro.

    Am I missing something here?
    Last edited by MaFloBra; 07-17-2016, 08:17 AM.
Working...
X