Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Property that can take a Blueprint reference or an Object reference?

I have a class that has an Object property to reference an object that is some data:

 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Vehicle)
 UVehiclePhysicsSetup* PhysicsSetup;

I prefer using an Object property instead of TSubclassOf because it has the flexibility of being able to be assigned an editor asset (created ahead of time in editor), or a runtime asset (constructed at runtime, say from data from the online backend). However it would be nice to be able to assign a Blueprint to it as well (assign the Blueprint's Default Object to the property). Is there anything that would allow this?

Product Version: UE 4.21
more ▼

asked Feb 28 '19 at 12:56 AM in C++ Programming

avatar image

8 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Without some extra code, no and it's actully limitation on C++ side, object creation function only accept UClass* (TSubclassOf is UClass* template) at most you can create object on object creation with CreateDefaultSubobject in constructor, but it wont let you pick subclass of object.

But you can do something like this:

  UPROPERTY(EditInstanceOnly, BlueprintReadOnly, Category = Vehicle)
  UVehiclePhysicsSetup* PhysicsSetup;
  UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta=(DisplayName="Physics Setup"),Category = Vehicle)
  TSubclassOf<UVehiclePhysicsSetup> PhysicsSetupClass;

This will make 2 varables visually visible as in blueprint defaults as UClass and in level property editor as object. Now on begin play you would check if PhysicsSetupClass is not null, if it is not null, create object of that class.

Now about extra "extra code"... if UVehiclePhysicsSetup is just class holding variables, you might consider turn it in to asset type and save those as assets instaed of blueprint classes. As assets they will exist as selectable object in blueprint defaults. By default if you don't define editor for your asset type, it will open it in property editor


There also quicker method by making UDataAsset class


Only downside of this method is you won't have fency menu entry for your asset creation (you will need to create it via "Data Assert") and you wont be able to control appearance of the asset in Content Browser, as well as potentially making custom editor for it

more ▼

answered Feb 28 '19 at 02:50 AM

avatar image

36.6k 932 169 1111

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question