A custom UClass not visible in Blueprint create menu!

Hi,

i crerated a custom class which inherits from UObject , but it’s not visible in the Blueprint create menu !

image

Can’t create a BP based on that class as it’s not visible
Anyone can help with that !?

Write the UCLASS like this:

UCLASS(BlueprintType, Blueprintable)

Documentation

2 Likes

correct!

1 Like

Awesome :smiley:

Really appreciated !
Thank you !

@Roy_Wierer.Seda145 one more question,

i have the asset created now, but do you know now why it’s not visible when i try to load it to the field ?

image

image

If that is a property field on the editor panel of type “Object reference” then it makes sense that there is nothing to select. Those objects do not exist at that point, instead you should make the property type “class reference” or “Soft Object Ptr”.

Image by ClockworkOcean:
43a6c08f01a59d4c50f9c14b00fbc3adcc5d51ea_2_463x500

1 Like

It is actually a variable in the car controller C++ class

I created a blueprint based on the CarEngine class and i wanted to add it to another blueprint based on this ACarController class from the image !

image

EDIT : hmm i also created Objcet Reference variable in the car BP to see if i can load it from there but still doesn’t show up

Yes but there is a difference between an object reference and a class reference. To be able to make an object reference to an object, the object must exist. Which means, an object of class UCarEngine must be spawned before a reference to it can be made.

So it you make a property like this you can set the class within Blueprint without requiring a spawned object:

UPROPERTY(EditAnywhere)
TSubclassOf<UCarEngine> CarEngineClass;

With that class, you can spawn as many objects as you like and those objects can be stored in a property of type:

UPROPERTY(EditAnywhere)
UCarEngine* CarEngineInstance;

In blueprint “TSubclassOf” is similar to the purple colored variable where an object reference is the blue color.

2 Likes

Hey @Roy_Wierer.Seda145

using a “TSubclassOf<>” variable actually did the job. I don’t understand how it works in general, but i had it working this way:

UCarEngine carEngine = Cast<UCarEngine>(carEngineSubClass.Get()->GetDefaultObject());

where carEngineSubClass is of type TSubclassOf;

Thanks for the help :slight_smile: