Asset Select Box in Plugin slate

After hours of swimming in source code, I hope someone here could help me.

How would one create Asset selection box in slate of plugin?

I have made bit of progress using SObjectPropertyEntryBox, but it does not behave properly. Upon selecting, it remains “None” and it does not have thumbnail. OnObjectChanged triggers though, which is nice.

FLevelEditorPluginEdModeToolkit::Init(const TSharedPtr<IToolkitHost>& InitToolkitHost)
[...]
+ SVerticalBox::Slot()
	.HAlign(HAlign_Center)
	.AutoHeight()
	[
		SNew(SObjectPropertyEntryBox)
		.AllowedClass(UPaperTileMap::StaticClass())
		.OnObjectChanged(FOnSetObject::CreateStatic(&FLevelGen2PluginModule::OnObjectChanged))
		//.PropertyHandle(this->MyTileMap)
		//.ThumbnailPool(???)
	]
[...]

As far as my research goes, the problem is that I need to link SObjectPropertyEntryBox to a variable to edit via PropertyHandle(IPropertyHandle handle). But to create IPropertyHandle, one would need IDetailCustomization. I have tried doing all of that, but CustomizeDetails() inside IDetailCustomization class never executed for me, and it felt too complicated for what I was trying to achieve.

Does anyone have any pointers?

2 Likes

Did you study arguments?

There simple object path that can be used insted of PropertyHandle

My guess is this widget was made to automaticly update state to 1. allow devloper to validate selection 2. as it was primerly made for property editor which is also display changing state of properties, especially in read only mode (VisibleAnywhere)

And you just need to enable Thumbnail:

If you got Slate class, google it to fins API reference age for it and then check FArguments and you will have full argument list

1 Like

Thanks for the pointers, using object path instead of Property Handle enabled to set/get selected object value.
But in regards to the thumbnail, DisplayThumbnail is true by default. It appears it needs ThumbnailPool to actually display the thumbnail. To get the thumbnail pool, one would still need the DetailBuilder. I hoped I could get the pool using FPropertyEditorModule::GetThumbnailPool(), but that is a private method. Am I missing something obvious?

I checked and all you need is to make one:

in header declere pool:

TSharedPtr<FAssetThumbnailPool> AssetThumbnailPool;

And init like this in cpp:

AssetThumbnailPool = MakeShareable(new FAssetThumbnailPool(24));
1 Like

I haven’t hooked events yet but I have something like this that can filter by class type and have goto and browse buttons

SNew(SObjectPropertyEntryBox)
.DisplayBrowse(true)
.DisplayThumbnail(true)
.AllowedClass(UTexture2D::StaticClass())
.EnableContentPicker(true)
1 Like

include “ThumbnailRendering/ThumbnailManager.h”
UThumbnailManager::Get().GetSharedThumbnailPool()