# Custom thumbnail for class

**URL:** <https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205>\
**Category:** C++\
**Tags:** icon, thumbnail, unreal-engine, question, CPP\
**Created:** [July 16, 2017, 8:23am UTC](https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205 "2017-07-16T08:23:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanashi88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nanashi88](https://forums.unrealengine.com/u/nanashi88)\
**Post date:** [July 16, 2017, 8:23am UTC](https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205/1 "2017-07-16T08:23:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MatzeOGH](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MatzeOGH](https://forums.unrealengine.com/u/MatzeOGH)\
**Post date:** [July 16, 2017, 8:37am UTC](https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205/2 "2017-07-16T08:37:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nanashi88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nanashi88](https://forums.unrealengine.com/u/nanashi88)\
**Post date:** [July 16, 2017, 1:09pm UTC](https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205/3 "2017-07-16T13:09:18Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![nanashi88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nanashi88](https://forums.unrealengine.com/u/nanashi88)\
**Post date:** [July 16, 2017, 1:26pm UTC](https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205/4 "2017-07-16T13:26:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jackblue](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jackblue/32/88706_2.png) [@Jackblue](https://forums.unrealengine.com/u/Jackblue)\
**Post date:** [July 16, 2017, 8:57pm UTC](https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205/5 "2017-07-16T20:57:50Z")

</div>

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](https://wiki.unrealengine.com/Creating_an_Editor_Module)

---

<div class="post-metadata">

**Author:** ![nanashi88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nanashi88](https://forums.unrealengine.com/u/nanashi88)\
**Post date:** [July 17, 2017, 8:52am UTC](https://forums.unrealengine.com/t/custom-thumbnail-for-class/400205/6 "2017-07-17T08:52:33Z")

</div>

@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 !
