Interfaces in C++
This wiki article was originally written by Rama and received contributions from HuntaKiller, DarkGaze, and Ruhrpottpatiot.
Overview
Creating The Interface
ReactsToTimeOfDay.h
#pragma once
#include "ReactsToTimeOfDay.generated.h"
/**
* Must have BlueprintType as a specifier to have this interface exposed to blueprints.
* With this line you can easily add this interface to any blueprint class.
*/
UINTERFACE(BlueprintType)
class MYPROJECT_API UReactsToTimeOfDay : public UInterface {
GENERATED_UINTERFACE_BODY()
};
class MYPROJECT_API IReactsToTimeOfDay {
GENERATED_IINTERFACE_BODY()
public:
// classes using this interface must implement ReactToHighNoon
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "MyCategory")
bool ReactToHighNoon();
//classes using this interface may implement ReactToMidnight
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "MyCategory")
bool ReactToMidnight();
};ReactsToTimeOfDay.cpp
Using An Interface With C++ Classes
Flower.h
Flower.cpp
Frog.h
Frog.cpp
Determining If a Given Actor Has The Interface
The Magic Interfaces
Overriding Behaviour In Blueprints
Summary
Last updated
Was this helpful?

