Hello all.
I was trying to make any mesh to play videos. With a solver to hold all media players, textures and so on. And all right, even the interface works well until I tried to create a function in the interface that returns a Array with a struct created on other header file. Then it throws that error warning of a circular dependency even when im using foward declaration
include “CoreMinimal.h” include “MediaPlayer.h” include “MediaTexture.h”
//include “VideoMeshInterface.h” //include the interface include “GameFramework/Actor.h” include “Kismet/GameplayStatics.h” include “VideoMeshSolver.generated.h”
USTRUCT(BlueprintType) //STRUCT
struct FVideoSettings
{
GENERATED_BODY()
//variables and stuff
};
UCLASS()
class VIDEOMESH_API AVideoMeshSolver : public AActor, public IVideoMeshInterface
{
GENERATED_BODY()
//variables and stuff
}
VideoMeshInterface.h:
#pragma once
include “CoreMinimal.h” include “UObject/Interface.h” include “VideoMeshSolver.h” //include the class with the struct include “VideoMeshInterface.generated.h”
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UVideoMeshInterface : public UInterface
{
GENERATED_BODY()
};
class VIDEOMESH_API IVideoMeshInterface
{
GENERATED_BODY()
include “CoreMinimal.h” include “Components/SkeletalMeshComponent.h” include “VideoMeshInterface.h” include “VideoMeshSolver.h” //include the class and struct include “VideoSkeletalMeshComponent.generated.h”
UCLASS(ClassGroup = Rendering, meta = (BlueprintSpawnableComponent))
class VIDEOMESH_API UVideoSkeletalMeshComponent : public USkeletalMeshComponent, public IVideoMeshInterface
{
GENERATED_BODY()
//variables and stuff
}
Sorry for the delay the copied code pasted the wrong quotation marks and was spewing out compile errors.
Swapped out the _API for my project just replace it with your own.
VideoMeshInterface.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
//#include "VideoMeshSolver.h" //include the class with the struct
#include "VideoMeshInterface.generated.h"
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UVideoMeshInterface : public UInterface
{
GENERATED_BODY()
};
class CIRCLEDEP_API IVideoMeshInterface
{
GENERATED_BODY()
public:
//UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Video)
TArray<struct FVideoSettings> getSettings();
};
VideoMeshSolver.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "MediaPlayer.h"
#include "MediaTexture.h"
#include "VideoMeshInterface.h" //include the interface
#include "GameFramework/Actor.h"
#include "Kismet/GameplayStatics.h"
#include "VideoMeshSolver.generated.h"
USTRUCT(BlueprintType) //STRUCT
struct FVideoSettings
{
GENERATED_BODY()
//variables and stuff
};
UCLASS()
class CIRCLEDEP_API AVideoMeshSolver : public AActor, public IVideoMeshInterface
{
GENERATED_BODY()
//variables and stuff
TArray<FVideoSettings> getSettings();
};
VideoSkeletalMeshComponent.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/SkeletalMeshComponent.h"
#include "VideoMeshInterface.h"
#include "VideoMeshSolver.h" //include the class and struct
#include "VideoSkeletalMeshComponent.generated.h"
UCLASS(ClassGroup = Rendering, meta = (BlueprintSpawnableComponent))
class CIRCLEDEP_API UVideoSkeletalMeshComponent : public USkeletalMeshComponent, public IVideoMeshInterface
{
GENERATED_BODY()
//variables and stuff
TArray<FVideoSettings> getSettings();
};
For future projects it’s better to isolate the struct to it’s own file.