Custom classes creatable from the editor's propperty drop down

Hello!

I’m onversion 4.10, trying to figure out exactly how to create custom classes creatable from the editor’s property drop down menu.

To be exact, I’m creating a new object (lets call it MyObject) like this:


#pragma once

#include "Object.h"
#include "MyObject.generated.h"

/**
 * 
 */
UCLASS(Blueprintable, editinlinenew, BlueprintType, ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class TWINSTICK_API UMyObject : public UObject
{
	GENERATED_BODY()

public:
	UMyObject(const FObjectInitializer& Init);
};

Now I create a property in one of my existing classes like this:


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnvironmentObjectOptions")
	class UMyObject* Test;

I can see that Test property in editor, but when I click it, I get an empty list.

On the other hand, when I write it like this:


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnvironmentObjectOptions")
	TSubclassOf<class UMyObject> Test;

Then I get UMyObject on the list, so editor knows about UMyObject class

Sould someone explain what am I doing wrong with my test object?

Thanx!

Your UPROPERTY needs the “Instanced” (documentation) specifier, back in UDK it was “EditInline” (documentation) which still exists but now (not sure which version this happend in) you’ll get an error message that it should no longer be used (directly).

Thank you, it shows my class now, but when I click on my object on the list, I get a crash with a log like this:


MachineId:AC4FD33F4F1B958515BFDBBD1918B548
EpicAccountId:29e690e1cafa4855a884bf2474fe7a14

Unknown exception - code 00000001 (first/second chance not available)

"Assertion failed: *Iter [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Editor\DetailCustomizations\Private\BodyInstanceCustomization.cpp] [Line: 133] 
"

UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\misc\outputdevice.cpp:374]
UE4Editor_DetailCustomizations!FBodyInstanceCustomization::CustomizeChildren() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\detailcustomizations\private\bodyinstancecustomization.cpp:134]
UE4Editor_PropertyEditor!FDetailPropertyRow::OnItemNodeInitialized() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\propertyeditor\private\detailpropertyrow.cpp:223]

By the way, why I had to add instanced to my propperty to get it to work for UObject, but it worked without it if I changed the inheritance for my test object to ActorClass?

I’m sorry, that crash is actually related to some other issues I’m having.

Read it carefully (you can remove the “class” keyword if your class is forward declared earlier or included, which might make it a bit easier to follow):


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnvironmentObjectOptions")
UMyObject* Test;

Pointer to a MyObject object.


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnvironmentObjectOptions")
TSubclassOf<UMyObject> Test;

Subclass of MyObject.

The former is a MyObject instance, which is what you want. The latter is just a MyObject class, which allows you to specify a type of MyObject.

The Instanced keyword, as mentioned, pulls in a bunch of editor magic to automatically create an instance using a drop down menu.