Announcement

Collapse
No announcement yet.

How do I use a mesh rendering for thumbnails?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I use a mesh rendering for thumbnails?

    Hi all, I have run into a problem that I feel should have an easy fix but does not seem to be jumping out at me. I have created a new UObject that contains some data useful for my project and a UStaticMesh* var. I would like to have the thumbnail of my uasset in the content browser show the currently appointed static mesh. A good example of exactly what I want to emulate is UFoliageType. However, just copying everything I found while exploring the source is not enough. My uasset thumbnail is still the name of my class with a white color value.

    As you can see in the image below the FoliageType displays the mesh I am testing with (though it fails regardless of the mesh) and the TestObject displays its name. Both have the same reference UStaticMesh*.
    I want TestObject to display the mesh like the FoliageType

    I would ideally like the following which I have photo-shopped for clarity. Retaining the white color value (or being able to set it) on the bottom is useful to let me know this is my special class.
    Click image for larger version  Name:	DesiredTestObjectThumbnail.png Views:	1 Size:	13.0 KB ID:	1574715

    To my current understanding, to get what I would like for the thumbnail I will need to make a StyleSet and perhaps other things. After a fair bit of research into the topic I could not find any reasonable path forward to do this shy of building a lot of code to custom render the mesh on the fly. This would be similar to the UFoliageType_ISMThumbnailRenderer. However, that appears to render the foliage inside the foliage pane and not the thumbnails viewed in the content browser. Before I jumped into that unfortunately large body of work I figured it would be good to ask around the forums.

    I am hoping that someone more familiar with thumbnails in the editor can help me get where I need to be. And/or that it is as simple as calling the magic function I somehow overlooked to use the built in system already in use for multiple UObject types.

    I am currently using UE4 version 4.21.1 on windows

    ------------------------

    So that my state can easily be understood I have composed a test object I have been testing out ideas with to prevent me from butchering my other work:

    Code:
    // TestObject.h
    
    #pragma once
    
    #include "CoreMinimal.h"
    #include "UObject/Object.h"
    
    #include "TestObject.generated.h"
    
    class UStaticMesh;
    
    UCLASS()
    class UTestObject : public UObject
    {
      GENERATED_BODY()
    
    public:
      UPROPERTY(EditAnywhere, meta = (DisplayThumbnail = "true")) UStaticMesh* Mesh = nullptr;
      float data0;
      int data1;
      bool data2;
    };
    TestObject.cpp is effectively blank (just the header file include for now)

    Code:
    // TestObjectFactory.h
    
    #pragma once
    
    #include "CoreMinimal.h"
    #include "UObject/ObjectMacros.h"
    #include "Factories/Factory.h"
    #include "TestObjectFactory.generated.h"
    
    UCLASS()
    class UTestObjectFactory : public UFactory
    {
      GENERATED_UCLASS_BODY()
    
      // UFactory interface
      virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
      virtual uint32 GetMenuCategories() const;
      // End of UFactory interface
    };
    Code:
    // TestObjectFactory.cpp
    
    #include "TestObjectFactory.h"
    #include "AssetTypeCategories.h"
    #include "TestObject.h"
    
    UTestObjectFactory::UTestObjectFactory(const FObjectInitializer& ObjectInitializer)
      : Super(ObjectInitializer)
    {
      bCreateNew = true;
      bEditAfterNew = true;
      SupportedClass = UTestObject::StaticClass();
    }
    
    UObject* UTestObjectFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
    {
      auto NewTestObject = NewObject(InParent, Class, Name, Flags | RF_Transactional);
    
      return NewTestObject;
    }
    
    uint32 UTestObjectFactory::GetMenuCategories() const
    {
      return EAssetTypeCategories::Misc;
    }

    I had initially assumed that the
    meta = (DisplayThumbnail = "true")
    tag that existed on the mesh in the FoliageType was all that was needed. The documentation isn't particularly clear on what this metagata specifier actually does.
    Indicates that the property is an Asset type and it should display the thumbnail of the selected Asset.
    Does this mean that it should display the thumbnail of the asset in the details panel (which it does by default) or in place of the thumbnail of my UTestObject? I have not seen it have an effect so I cannot tell.



    Last edited by adoxon; 01-21-2019, 11:07 PM.
Working...
X