# PostInitProperties funcitonality for a USTRUCT

**URL:** <https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135>\
**Category:** Community & Industry Discussion\
**Tags:** uobject, ustruct, unreal-engine, Scripting, question\
**Created:** [May 15, 2018, 7:46am UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135 "2018-05-15T07:46:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben0nator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ben0nator](https://forums.unrealengine.com/u/Ben0nator)\
**Post date:** [May 15, 2018, 7:46am UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/1 "2018-05-15T07:46:33Z")

</div>

I’m trying to create a new BlueprintType with a USTRUCT. I expect to be able to do the following:

- Make new variable in a blueprint (with my new type)
- Set defaults for the new variable (in the blueprint)
- The other members of the variable are initialized **based on the specified defaults**

Obviously I cannot use the PostInitProperties function in a struct since it is defined in UObject.

But if I change my struct to a class derived from UObject, I can’t edit default values in the BP editor:

 ![241184-ustruct-vs-uclass.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/3/8635fc5f65f51da4625f65467a87982d8d974693.png)

* * *

In other words, how do I remove the need for a custom initialization function? 99.9% of the time, it will be in this exact spot:

![241252-init.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/6/f/26f0e62a2a424174a2abd8865fe1728049de4365.png)

* * *

Or look at it this way:

In code alone, I’d just use parameters in the constructor to instantiate unique instances of a class/struct. How do I accomplish this with my C++ class when I am instantiating it in UE Blueprints?

I’d like to use it as a variable in Blueprints, so I don’t want to have to create child Blueprint classes of my data class every time I simply need different defaults.

* * *

Is something like this possible, a feature request, or against UE4 standards/workflow?

---

<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:** [May 15, 2018, 9:16pm UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/2 "2018-05-15T21:16:32Z")

</div>

I dont think that possible, default are stored in CBOs Class Defaults Object and struct is stored as a part of a class/object an both defaults and serialization in to the file, when you got PostInitProperties this includes all structs in the class.

You can create custom widget for property editor for your struct, maybe you could try doing something with that and leave constrcutor to do the work on C++ side:

> **[Details Panel Customization](https://docs.unrealengine.com/5.1/en-US/details-panel-customization-in-unreal-engine/)**
>
> Guide to customizing the display of properties in the Details panels within Unreal Editor.

Doing construction nodes is also valid solution but user can still normally make structs with make node

---

<div class="post-metadata">

**Author:** ![Ben0nator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ben0nator](https://forums.unrealengine.com/u/Ben0nator)\
**Post date:** [May 16, 2018, 3:01am UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/3 "2018-05-16T03:01:03Z")

</div>

I’m not sure I understand. Could you elaborate on the two workarounds you mentioned?  
Concerning the first, I don’t think I can add access to properties through UI customization?

---

<div class="post-metadata">

**Author:** ![ThD\_ManiaC](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thd_maniac/32/1194665_2.png) [@ThD\_ManiaC](https://forums.unrealengine.com/u/ThD_ManiaC)\
**Post date:** [January 23, 2021, 10:25am UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/4 "2021-01-23T10:25:48Z")

</div>

Use the UCLASS approach and mark it as UCLASS( Blueprintable, DefaultToInstanced, EditInlineNew ). Define your TestArray as UPROPERTY( Instanced, EditAnywhere ). Should get you all the benefits.  
You may find additional information in the code-definition of those macros and on answerhub ;D though, setting to defaults and saving may be some fiddling…

---

<div class="post-metadata">

**Author:** ![dokipen](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dokipen/32/1145419_2.png) [@dokipen](https://forums.unrealengine.com/u/dokipen)\
**Post date:** [June 13, 2021, 11:51am UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/5 "2021-06-13T11:51:00Z")

</div>

I’ve had the same issue as OP, and have been trying this, but I still see “Default Value” instead of the properties I have in the UCLASS. Here’s the code…

 ![341358-ue4editor-42fzcwfrgd.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/8/bd81d122d366fab0e2634e0f3da009c437a36e01.png)

```
#pragma once

#include "CoreMinimal.h"
#include <Eigen/Dense>
#include "EigenMatrix.generated.h"

UCLASS(BlueprintType, Blueprintable, DefaultToInstanced, EditInlineNew )
class DOKIFLUIDDEVTOOLS_API UEigenMatrix : public UObject
{
	GENERATED_BODY()
public:
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player Variables")
	int32 rows = 1;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player Variables")
	int32 columns = 1;

	Eigen::MatrixXf matrix;
};
```

---

<div class="post-metadata">

**Author:** ![ThD\_ManiaC](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thd_maniac/32/1194665_2.png) [@ThD\_ManiaC](https://forums.unrealengine.com/u/ThD_ManiaC)\
**Post date:** [June 14, 2021, 7:42am UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/6 "2021-06-14T07:42:05Z")

</div>

using the Meta specifiers on the UClass defenition and at the UProperty, it looks like this which is like using a Struct but with the actual Class selectable:

![341416-instancedclassproperty.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/3/4b36ef5f08a220926bae9ca26ba3322e456aa06e.jpeg)

```
UCLASS( BlueprintType, Blueprintable, DefaultToInstanced, EditInlineNew )
class SPACENEBULASTARFIELDV3_API UEigenMatrix : public UObject
{
	GENERATED_BODY()

public:
	UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Player Variables" )
		int32 rows = 1;
	UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Player Variables" )
		int32 columns = 1;

	FMatrix matrix;
};

UCLASS()
class SPACENEBULASTARFIELDV3_API ATestActor : public AActor
{
	GENERATED_BODY()

public:
	UPROPERTY( Instanced, EditAnywhere, BlueprintReadWrite, Category = "Player Variables" )
		UEigenMatrix* NewVar0;
};
```

---

<div class="post-metadata">

**Author:** ![dokipen](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dokipen/32/1145419_2.png) [@dokipen](https://forums.unrealengine.com/u/dokipen)\
**Post date:** [June 14, 2021, 11:12pm UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/7 "2021-06-14T23:12:45Z")

</div>

Thats good to see, however I’m not using my UEigenMatrix as a property in another Actor class. I’m using it directly as a blueprinttype (potentially in a blueprint utlility).

---

<div class="post-metadata">

**Author:** ![officernickwilde](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/officernickwilde/32/547477_2.png) [@officernickwilde](https://forums.unrealengine.com/u/officernickwilde)\
**Post date:** [July 3, 2023, 8:38pm UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/8 "2023-07-03T20:38:43Z")

</div>

This seems to be for creating Blueprint classes only, OP wants to create a class/struct for BP variable types (like, variables in a BP, not new BPs)

---

<div class="post-metadata">

**Author:** ![officernickwilde](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/officernickwilde/32/547477_2.png) [@officernickwilde](https://forums.unrealengine.com/u/officernickwilde)\
**Post date:** [July 3, 2023, 8:40pm UTC](https://forums.unrealengine.com/t/postinitproperties-funcitonality-for-a-ustruct/425135/9 "2023-07-03T20:40:14Z")

</div>

Have anyone found a solution to this? I’m in the same situation, currently considering to go for a struct and correct data every time I access it, but that feels quite wrong tbh
