Download

Add an asset box to Slate (details) menu?

Hi, I’m trying to add an asset (default static mesh selection) box to the slate menu. The same one unreal uses when selecting meshes for static mesh component.

Here’s the .h code


UStaticMesh* Mesh;

And the actual slate section


    + SScrollBox::Slot()
    .Padding(10)
    
        SNew(SWidget)
        + SWidget::Slot()
        .Padding(0)
        
            Mesh //<--- ?????
        ]
    ];



I’m not sure what to put here in slate to make the actual mesh selector appear. Any help is appreciated!

FAssetThumbnail will create the thumbnail widget for you, so you’ll need to allocate one as well as an FAssetThumbnailPool object. You can see how this is all setup in SGenericAssetShortcut.



      // In your Widget Header.
      TSharedPtr<FAssetThumbnailPool> MyThumbnailPool;
      TSharedPtr<FAssetThumbnail> MyThumbnail;

       // In your Widget Construct method...
       FAssetThumbnailPool = MakeShareable(new FAssetThumbnailPool(16, false));
       MyThumbnail = MakeShareable(new FAssetThumbnail(Mesh, GenericAssetShortcutConstants::ThumbnailSize, GenericAssetShortcutConstants::ThumbnailSize, MyThumbnailPool));

     // ...
    + SScrollBox::Slot()
    .Padding(10)
    
        SNew(SWidget)
        + SWidget::Slot()
        .Padding(0)
        
            MyThumbnail->MakeThumbnailWidget()
        ]
    ];



If you ever want to know how some UI widget is setup, just turn on the Widget Reflector in the Dev Tools in the Editor and you can see exactly where / what a widget is made out of.

Thanks for the info! However neither SGenericAssetShortcut nor SGenericAssetShortConstraints exist within the engine. Are those are the correct words?
There was also errors with


MakeShareable(new FAssetThumbnailPool(16, false));

however I’m unable to find proper implementation of that.

Tried widget reflector that showed me SAssetDropTarget on the mesh selector, couldn’t find anything relating to the above. If I could get that working I’d be all set. :slight_smile:

Sorry, those were things I added to clean up some stuff.

SAssetShortcut is the default name of the widget that displays an asset preview. It’s not exported by default (it actually only exists in the SAssetFamilyShortcutBar.cpp) so you’ll likely need to do some copy / paste to make it into it’s own widget you can re-use.