Custom thumbnail for class

@Jackblue thank you for replay.

what if I do something like:

    #ifdef WITH_EDITOR
       #include "SlateCore.h"
       class FMyDefaultGameModuleImpl : public FDefaultGameModuleImpl { ....... }
       IMPLEMENT_PRIMARY_GAME_MODULE(FMyDefaultGameModuleImpl, MG3, "MG3");
    #else
       IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, MG3, "MG3");
    #endif

cuz I only need to change some class thumbnails while developing. and thats it !

Hi,

I am trying to set custom thumbnails, in the editor, for my c++ actor classes, since to search image by eye is faster than to read class names, especially when there are alot classes in one folder.

after some search I have reached to do this:

MyActor.h

class AMyActor : public AActor {
...
static TSharedPtr< class FSlateStyleSet > StyleSet;

}

MyActor.cpp

TSharedPtr< FSlateStyleSet > AMyActor::StyleSet = nullptr;

void AMyActor::foo() {
	StyleSet = MakeShareable(new FSlateStyleSet("MyActorStyleSet"));
	StyleSet->SetContentRoot(FPaths::EngineContentDir() / TEXT("Editor/Slate"));
	StyleSet->SetCoreContentRoot(FPaths::EngineContentDir() / TEXT("Slate"));

	auto brush = new FSlateImageBrush( 
		StyleSet->RootToContentDir(TEXT("Icons/AssetIcons/PaperCharacter_64x"),TEXT(".png"))
		, FVector2D(64.0f, 64.0f)
		);

	StyleSet->Set("ClassThumbnail.AMyActor", brush);
	FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
}

my questions is:

1- where should I call foo() ?
I have tried to call it from PostInializeComponents() but the editor crashed. ( noob ^^)

2- is this line ok ?
StyleSet->Set(“ClassThumbnail.AMyActor”, brush);

thank you.

you have to do that in the StartupModule() method of your game module.

thank you MatzeOGH . this solved it ^^
still I am not sure if what I have did is the right way to do it.
I’ll post what I did in the next comment …

for beginners like me, this solution should work : (I am not sure if this way is ok to edit my game module )

my project name MG3, the file MG3.cpp by default is:

#include "MG3.h"
IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, MG3, "MG3");

so I have edited it to the following:

#include "MG3.h"

#ifndef WITH_EDITOR
IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, MG3, "MG3");
#else

#include "SlateStyle.h"
#include "SlateStyleRegistry.h"

class FMyDefaultGameModuleImpl
	: public FDefaultGameModuleImpl {
public:
	static TSharedPtr< class FSlateStyleSet > StyleSet;
	virtual void StartupModule() override {
		StyleSet = MakeShareable(new FSlateStyleSet("PlyrOPStyleSet"));
		StyleSet->SetContentRoot(FPaths::EngineContentDir() / TEXT("Editor/Slate"));
		StyleSet->SetCoreContentRoot(FPaths::EngineContentDir() / TEXT("Slate"));

		auto brush = new FSlateImageBrush(
			StyleSet->RootToContentDir(TEXT("Icons/AssetIcons/PaperCharacter_64x"), TEXT(".png"))
			, FVector2D(64.0f, 64.0f)
			);

		StyleSet->Set("ClassThumbnail.MPlayerOP", brush);
		FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
	}

	virtual void ShutdownModule() override {
		FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get());
		ensure(StyleSet.IsUnique());
		StyleSet.Reset();
	}

};

TSharedPtr< FSlateStyleSet > FMyDefaultGameModuleImpl::StyleSet = nullptr;

IMPLEMENT_PRIMARY_GAME_MODULE(FMyDefaultGameModuleImpl, MG3, "MG3");
#endif

MPlayerOP is the class name that I want to change its thumbnail.

thanks for everyone in ue answers ^^ . special thanks to MatzeOGH.

In my opinion, setup this kind of stuff on your game module is tricky.
Create an Editor module to add custom style to assets, actors, etc…

More informations here : A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums