Skip to content

Instantly share code, notes, and snippets.

Created June 17, 2014 23:28
Show Gist options
  • Save anonymous/20180e658dba55785d3d to your computer and use it in GitHub Desktop.
Save anonymous/20180e658dba55785d3d 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()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment