A way to use SPropertyEditorClass?

Can’t include SPropertyEditorClass.h cuz it’s inside private part of Property Editor, is there a way to use it somehow? I found another class in public directory that reflects SPropertyEdtiorClass, its called SClassPropertyEntryBox, but it doesn’t have IClassViewerFilter argument that makes it pretty useless for me cuz i need to exclude some classes from the list, any ideas?

Hi Repin_Design,

Is it a Class selector that you’re after? Have you looked into SClassViewer?

If not, maybe it could help, it’s simple:

	FClassViewerModule& ClassViewerModule = FModuleManager::LoadModuleChecked<FClassViewerModule>("ClassViewer");

	FClassViewerInitializationOptions ClassViewerOptions;
	ClassViewerOptions.Mode							= EClassViewerMode::ClassPicker;
	ClassViewerOptions.DisplayMode					= EClassViewerDisplayMode::TreeView;
	ClassViewerOptions.bShowObjectRootClass			= true;
	ClassViewerOptions.bIsPlaceableOnly				= true;
	ClassViewerOptions.bIsBlueprintBaseOnly			= true;
	ClassViewerOptions.bShowUnloadedBlueprints		= true;
	ClassViewerOptions.bEnableClassDynamicLoading	= true;
	ClassViewerOptions.NameTypeToDisplay			= EClassViewerNameTypeToDisplay::Dynamic;
	ClassViewerOptions.InitiallySelectedClass=CurrentOptions->classType;
	filter=MakeShareable(new FClassFilter(CurrentOptions->classType));

#if ENGINE_MAJOR_VERSION>4
	ClassViewerOptions.ClassFilters.Add(filter.ToSharedRef());
#else
	ClassViewerOptions.ClassFilter=filter.ToSharedRef();
#endif


	ClassViewer=StaticCastSharedRef<SClassViewer>(ClassViewerModule.CreateClassViewer(ClassViewerOptions,FOnClassPicked::CreateSP(this,&FrdBPCreateFromActorsOptionsCustomization::OnClassPicked)));

1 Like

Looks like that is exacly what ive been looking for, thanks mate.

1 Like

Sry, just one more question, how exacly i create filters? I must inherit from IClassViewerFilter and override IsClassAllowed? I do understand this right?

Yes that’s the way, something like:

class FClassFilter : public IClassViewerFilter {
public:
	FClassFilter(UClass* addClass)	{ classList.Add(addClass); }
	TSet<const UClass*> classList;
	virtual bool IsClassAllowed(const FClassViewerInitializationOptions& initOptions,const UClass* tstClass,TSharedRef<FClassViewerFilterFuncs> filterFuncs) override { 
		return filterFuncs->IfInChildOfClassesSet(classList,tstClass)==EFilterReturn::Passed;
	}
	virtual bool IsUnloadedClassAllowed(const FClassViewerInitializationOptions& initOptions,const TSharedRef<const IUnloadedBlueprintData> unloadedClassData,TSharedRef<FClassViewerFilterFuncs> filterFuncs) override { 
		return filterFuncs->IfInChildOfClassesSet(classList,unloadedClassData)==EFilterReturn::Passed;
	}
};

with it like that, you can construct it with one class, and if you want more just add them to the classList.

filter=MakeShareable(new FClassFilter(MyClassTypeWanted));
filter->classList.Add(AnotherClassType);

And just pass it in like that first bit of code in the first reply…

1 Like

Thank you.

1 Like

I did everything as u said and it works well.

1 Like

May i ask u one last quetion about that SClassViewer? One thing bothers me, what exacly IPropertyHandle variable in FClassViewerInitializationOptions named PropertyHandle are used for in SClassViewer? Comment says it is property that ClassViewer are working on, but what exacly that means? And what kind of property should it be? I can add like UClass* property that be changed then u select class in SClassViewer? Or i understand it wrong? Can i use it to created object with Instanced object flag? Or i should do the proccess manualy using FOnClassPicked delegate? Then what i should use as PropertyHandle? Can it be NULL?

Yes that can be NULL, it’s only used with the Property Editor. That’s right, just use the FOnClassPicked to construct an object from the UClass.

https://docs.unrealengine.com/4.27/en-US/API/Editor/PropertyEditor/

1 Like