Announcement

Collapse
No announcement yet.

Why can't I add a default functionality for interface functions?

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

    Why can't I add a default functionality for interface functions?

    Hello,

    in the default .cpp file of a interface is written:

    // Add default functionality here for any IPooledObjectInterface functions that are not pure virtual.

    But this does not seem to work. I have an interface:

    Code:
    // Fill out your copyright notice in the Description page of Project Settings.
    
    #pragma once
    
    #include "CoreMinimal.h"
    #include "UObject/Interface.h"
    #include "PooledObjectInterface.generated.h"
    
    #define DebugPrintGreen(text) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 60.0f, FColor::Green,text)
    
    // This class does not need to be modified.
    UINTERFACE(MinimalAPI, Blueprintable)
    class UPooledObjectInterface : public UInterface
    {
    GENERATED_BODY()
    };
    
    /**
    *
    */
    class BRICKGAMEVRCPP_API IPooledObjectInterface
    {
    GENERATED_BODY()
    
    
    public:
    // called when this actor is taken from a pool. Should handle things like making the actor visible, enabling ticking etc.
    UFUNCTION(BlueprintNativeEvent, Category = "Pooled Object Interface")
    void OnTakenFromPool();
    
    // called when this actor is released to a pool. Should handle things like making the actor invisible, disabling ticking etc.
    UFUNCTION(BlueprintNativeEvent, Category = "Pooled Object Interface")
    void OnReleasedToPool();
    
    UFUNCTION(BlueprintNativeEvent, Category = "Pooled Object Interface")
    void OnAddedToPool();
    
    // release this actor to the pool. Should be called instead of DestroyActor().
    UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pooled Object Interface")
    void ReleaseToPool();
    virtual void ReleaseToPool_Implementation();
    };
    and in the .cpp file:

    Code:
    // Fill out your copyright notice in the Description page of Project Settings.
    
    
    #include "PooledObjectInterface.h"
    #include "../../Utils/ObjectPool/ObjectPoolFunctionLibrary.h"
    
    // Add default functionality here for any IPooledObjectInterface functions that are not pure virtual.
    
    void IPooledObjectInterface::ReleaseToPool_Implementation()
    {
    check(false);
    }
    I implement the interface in a BP, do NOT override ReleaseToPool and call ReleaseToPool on it. It should crash with the assert check(false). But it does nothing. It's like if the BP doesn't know the default functionality.
    What's wrong with this?

    Thanks,

    Thilo
Working...
X