How to do it...

  1. Create a new Interface called Selectable:
  1. Define the following functions inside ISelectable:
class CHAPTER_07_API ISelectable{  GENERATED_BODY()  // Add interface functions to this class. This is the class that will   // be inherited to implement this interface.public:    virtual bool IsSelectable();    virtual bool TrySelect();    virtual void Deselect();};
  1. Provide a default implementation for the functions, like so:
#include "Selectable.h"// Add default functionality here for any ISelectable functions that are not pure virtual.bool ISelectable::IsSelectable(){ GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Red, "Selectable"); ...

Get Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.