Creating new BlueprintTypes in C++

Hi,

I’m trying to create a new Blueprint type that exposes some members and member functions to Blueprints - no problem here - and allow editing of its properties in the details pane.
However, if I add a variable of my type to my Actor blueprint and make it editable, the only thing it shows in the details pane is its name and a field saying “None”.
None=(.png

So how do I set proper default values for custom Blueprint types, or what is it that I need to do for it to show it’s properties in the details pane?

Right now I have a UCLASS(BlueprintType) class UMyBPType : public UObject {…}, with all properties marked UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Something).

I know I could turn it into a Component, and then add it in the Components part of the Blueprint, that way it’ll get properly initialized, but most components don’t show their properties on the Blueprint Actor’s details pane either…

I’m not sure but I think the classes, that Actor(blueprints) are based on must inherit from AActor, UObject is not enough.

I don’t want a new base type of Blueprint, I want to create a type blueprints can use in variables

BlueprintType is not enough. You also need Blueprintable:



UCLASS(Blueprintable, BlueprintType)
class URPGEffectBase : public UObject 


Hmm, I gave that a try, but it didn’t change anything.
stillnothing.png

I don’t understrand what you trying to do ?

Class is just well class, you create class variable, and you can plug another blueprint to it with set properties.

Object is object. You spawn object from classes, or create them in level.

Wiki tutorials

Create Blueprint Functions (put them in any UCLASS() you want)

Create Blueprint-accessible variables in any UCLASS

After trying both of the above tutorials please let us know if there is some other functionality you are looking for

:slight_smile:

Rama

I know how to create blueprint accessible functions and variables.
What I want to do is create a class type that has properties and functions, and add one as a variable to a blueprint, and have it visible and editable, just like a bool, struct, whatever variable:

Let’s see if I understood correctly.

You have a class AMyClass that has properties and functions

You want to create a blueprint based on that class

You then want to be able to specify that blueprint as a property in another class/blueprint combo so they can be used.

If that’s the case, you can specify it, for example, as:


UPROPERTY(EditDefaultsOnly, Category=Configuration)
TSubclassOf<AMyClass> MyClass;

In the editor, you’ll be able to select in that field any class that extends AMyClass, including the Blueprints that extend it.

And then you can use SpawnActor or ConstructObject on that class. Depending on whether they are actors or just components (you can also “blueprint them”)

Is that what you meant?

S!

No, my class is not an actor, I don’t want to spawn it in the world. And I don’t want to base my blueprint on it, I simply want to put one as a variable into a blueprint.

sadfg.png&d=1399238376

All my class is supposed to do is hold some state, let the user change it on the actor, and calculate stuff with it.

I’m not sure if you can do what you want: being able to edit the values of the instance of a custom class that is not a blueprint. The usual way we solve that kind of problem is through blueprints that extend that class, in some cases with UPROPERTY(EditInstanceOnly…) so we can have several instances with specific values for each one.

I can’t help you there then, I’m afraid.

Cheers!

PD: I’ve done with Structs of basic properties, but not with any kind of class.

Well, I guess I can turn this class into an Actor and make my blueprint extend it - that makes the properties visible in the details pane, and I can call the functions (on myself…).
But that doesn’t seems right since my class is not an actor, it probably implements none of the interface an AActor should, and it has absolutely nothing to do with being placeable in the world.
Also, this only works once and seems backwards. There has to be a better way to hook a C++ class into Blueprints? It can show the properties of a struct variable fine, what’s the difference with a class?

No need for them to be AActors. As I said, they can be simple UObjects. No need to place them in the world, not replicated… If you don’t need all what AActor provides, you can use that as your base for the blueprint.

It works for a Struct of basic types, because it simply has to show a list of fields. If they did it with any kind of class, that class could have members that could also be classes… and that’s way more complicated to handle…

As you say, blueprints have this thing of classes/instances that it is sometimes blurry and I agree it’s not ideal, but I’m just trying to adapt to the mechanisms that UE4 provides :).

I think what you are looking for is the ‘custom Structs’ feature coming in 4.2!