Creating custom context menu entries for Assets

Custom Asset types commonly have special functions you wish to be able to perform on them. For example, converting images to sprites is an option you wouldn't want to add to any other Asset type. You can create custom context menu entries for specific Asset types in order to make those functions accessible to users.

How to do it…

  1. Create a new class based on FAssetTypeActions_Base. You'll need to include AssetTypeActions_Base.h in the header file.
  2. Override the following virtual functions in the class:
    virtual bool HasActions(const TArray<UObject*>& InObjects) const override; virtual void GetActions(const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder) override; virtual FText GetName() const override; ...

Get Unreal Engine 4 Scripting with C++ Cookbook 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.