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

**URL:** <https://forums.unrealengine.com/t/property-that-can-take-a-blueprint-reference-or-an-object-reference/444299>\
**Category:** Blueprint\
**Tags:** property, Class, unreal-engine, question\
**Created:** [February 28, 2019, 12:56am UTC](https://forums.unrealengine.com/t/property-that-can-take-a-blueprint-reference-or-an-object-reference/444299 "2019-02-28T00:56:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ConeBone](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ConeBone](https://forums.unrealengine.com/u/ConeBone)\
**Post date:** [February 28, 2019, 12:56am UTC](https://forums.unrealengine.com/t/property-that-can-take-a-blueprint-reference-or-an-object-reference/444299/1 "2019-02-28T00:56:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [February 28, 2019, 2:50am UTC](https://forums.unrealengine.com/t/property-that-can-take-a-blueprint-reference-or-an-object-reference/444299/2 "2019-02-28T02:50:39Z")

</div>

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

> **[Adding New Asset Types to UE4 | gmpreussner](https://gmpreussner.com/reference/adding-new-asset-types-to-ue4)**
>
> Adding custom asset types is an important, yet underused feature in Unreal Engine 4. This article shows how to accomplish this task and offers some deeper insights into the various APIs.

There also quicker method by making UDataAsset class

> **[UE4 C++ Data Assets](http://www.levelplusgames.com/ue4-c-data-assets/)**
>
> Today, I would like to write about the engine we are using in our new project, and that would be Unreal Engine 4. We've been experimenting with the engine lately to learn all of its features, and today I discovered...

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
