Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Chronojam/72a0fc73ccd9b586797c to your computer and use it in GitHub Desktop.
Save Chronojam/72a0fc73ccd9b586797c to your computer and use it in GitHub Desktop.
.h
#pragma once
#include "Ship_Component_Interface.generated.h"
/**
*
*/
UINTERFACE(MinimalAPI)
class UShip_Component_Interface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class IShip_Component_Interface
{
GENERATED_IINTERFACE_BODY()
public:
virtual void Foo() = 0;
};
.cpp
#include "Space.h"
#include "Ship_Component_Interface.h"
UShip_Component_Interface::UShip_Component_Interface(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
/**void IShip_Component_Interface::Foo()
{
}*/
#### ship comp ###
.h
#pragma once
#include "GameFramework/Actor.h"
#include "Ship_Component_Interface.h"
#include "ShipComponent.generated.h"
/**
*
*/
UCLASS()
class AShipComponent : public AActor, public IShip_Component_Interface
{
GENERATED_UCLASS_BODY()
UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
TSubobjectPtr<class UStaticMeshComponent> Mesh;
UPROPERTY(VisibleDefaultsOnly, Category = Utility)
TSubobjectPtr<class USceneComponent> DefaultRoot;
public:
virtual void Foo() OVERRIDE;
};
.cpp
#include "Space.h"
#include "ShipComponent.h"
AShipComponent::AShipComponent(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
DefaultRoot = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("Default"));
Mesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));
Mesh->RelativeLocation = FVector(0.f, 0.f, 0.f);
}
void AShipComponent::Foo()
{
}
## ??
Error 6 error LNK2001: unresolved external symbol "public: virtual void __cdecl AShipComponent::Foo(void)" (?Foo@AShipComponent@@UEAAXXZ) C:\Users\Calum\Documents\Unreal Projects\Space\Intermediate\ProjectFiles\ShipComponent.cpp.obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment