This is a big jumble of words, nut here it goes…
I’m working on a virtual tv studio, and I have an interface with the functions AddOutput, RemoveOutput, and GetRenderTarget implemented in C++ so the different bits of virtual equipment can talk to each other. I also have a camera using a USceneCaptureComponent2D setup in C++. The issue is, when I try to call any of the camera’s functions through the interface in Blueprint, it either complains that it isn’t marked as BlueprintCallable, or just doesn’t run. When I try to mark it as blueprint callable in my TVCamera.h file, it doesn’t let me compile, because I didn’t mark it as BlueprintImplementable like it is in the interface. When I mark it as BlueprintImplementable, it won’t compile because i’ve implemented it in C++. I need the interface to be BlueprintImplementable because I plan to make some simpler pieces of virtual equipment in Blueprint. What should I do?
TVCamera.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TVVideoInterface.h"
#include "Engine/TextureRenderTarget2D.h"
#include "TVCamera.generated.h"
class USceneCaptureComponent2D;
UCLASS()
class TVSYSTEM_API ATVCamera : public AActor, public ITVVideoInterface
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ATVCamera();
// Functions
UFUNCTION(BlueprintCallable, Category = "Video")
UTextureRenderTarget2D* AddOutput();
UFUNCTION(BlueprintCallable, Category = "Video")
bool RemoveOutput();
UFUNCTION(BlueprintCallable, Category = "Video")
UTextureRenderTarget2D* GetRenderTarget() const;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Components
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
USceneCaptureComponent2D* SceneCaptureComp;
// Properties
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
int ResolutionX;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
int ResolutionY;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
TEnumAsByte<ETextureRenderTargetFormat> RenderTargetFormat;
UTextureRenderTarget2D* RenderTarget;
// The amount of users using this camera
int Users;
// Functions
void UpdateIsRendering();
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
TVVideoInterface.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "TVVideoInterface.generated.h"
class UTextureRenderTarget2D;
// This class does not need to be modified.
UINTERFACE(Blueprintable)
class UTVVideoInterface : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class TVSYSTEM_API ITVVideoInterface
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
/* Add an output to this camera. Returns the RenderTarget for this source. */
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Video")
UTextureRenderTarget2D* AddOutput();
/* Remove an output from this source. If there are zero outputs on a camera, it will stop rendering. */
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Video")
bool RemoveOutput();
/* Gets a reference to the render target of the source. Do not use for output adding. */
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Video")
UTextureRenderTarget2D* GetRenderTarget();
};