Skip to content

Instantly share code, notes, and snippets.

@BaeMinCheon
Last active August 4, 2022 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaeMinCheon/109b251f1c88ae3f7e73dd711d0cc153 to your computer and use it in GitHub Desktop.
Save BaeMinCheon/109b251f1c88ae3f7e73dd711d0cc153 to your computer and use it in GitHub Desktop.
Custom RichTextBlockDecorator example code #1
// https://baemincheon.github.io/2022/07/28/how-the-rich-text-block-works-in-unrealengine/
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "UObject/Object.h"
#include "Fonts/SlateFontInfo.h"
#include "Styling/SlateTypes.h"
#include "Framework/Text/TextLayout.h"
#include "Framework/Text/ISlateRun.h"
#include "Framework/Text/ITextDecorator.h"
#include "Components/RichTextBlockDecorator.h"
#include "Engine/DataTable.h"
#include "RichTextBlockSomeWidgetDecorator.generated.h"
class ISlateStyle;
USTRUCT(Blueprintable, BlueprintType)
struct FRichSomeWidgetRow : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = Appearance)
FSlateBrush Brush;
UPROPERTY(EditAnywhere, Category = Appearance)
FText Text;
};
UCLASS(Abstract, Blueprintable)
class URichTextBlockSomeWidgetDecorator : public URichTextBlockDecorator
{
GENERATED_BODY()
public:
URichTextBlockSomeWidgetDecorator(const FObjectInitializer& ObjectInitializer);
virtual TSharedPtr<ITextDecorator> CreateDecorator(URichTextBlock* InOwner) override;
virtual const FRichSomeWidgetRow* FindSomeWidgetRow(FName TagOrId, bool bWarnIfMissing);
protected:
FRichSomeWidgetRow* FindRow(FName TagOrId, bool bWarnIfMissing);
UPROPERTY(EditAnywhere, Category=Appearance, meta = (RequiredAssetDataTags = "RowStructure=RichSomeWidgetRow"))
TObjectPtr<class UDataTable> ImageSet;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment