# Assigned UUserWidget\* inside of another widget is always reset after compile

**URL:** <https://forums.unrealengine.com/t/assigned-uuserwidget-inside-of-another-widget-is-always-reset-after-compile/450712>\
**Category:** UI\
**Tags:** hud, unreal-engine, UI, Widget, UE4, CPP, question\
**Created:** [June 15, 2019, 12:01am UTC](https://forums.unrealengine.com/t/assigned-uuserwidget-inside-of-another-widget-is-always-reset-after-compile/450712 "2019-06-15T00:01:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_11229cfe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_11229cfe](https://forums.unrealengine.com/u/anonymous_user_11229cfe)\
**Post date:** [June 15, 2019, 12:01am UTC](https://forums.unrealengine.com/t/assigned-uuserwidget-inside-of-another-widget-is-always-reset-after-compile/450712/1 "2019-06-15T00:01:00Z")

</div>

Hi,  
I try to dynamically create an interface using C++, but having an issue with UUserWidget.

The image attached shows some widgets assigned to the custom parent widget declared in C++ which is then placed within the main HUD widget of my project.

![279845-ui-01.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/8/058ab492c5750416e2b0fbc10cc0ce7082a17518.png)

Here is declaration of the _Type Button_ widget (other widgets declared the same way):

```
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Menu")
    UUserWidget * TypeButton;

```

My issue is that after the project is closed or code being compiled the assigned widget values are reset to None. I understand it happens because of the pointers being used, but how do I fix that?

This is after recompile:

![279846-ui-02.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/8/6286f13a4661ea3e54f692aac148f7eace16d311.png)

---

<div class="post-metadata">

**Author:** ![kevincvanhorn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kevincvanhorn](https://forums.unrealengine.com/u/kevincvanhorn)\
**Post date:** [June 15, 2019, 5:49am UTC](https://forums.unrealengine.com/t/assigned-uuserwidget-inside-of-another-widget-is-always-reset-after-compile/450712/2 "2019-06-15T05:49:13Z")

</div>

Check your BeginPlay function and constructor in both the code and the blueprint, it’s likely being overwritten in one of those. If thatS not the case try changing **EditAnywhere** to **EditDefaultsOnly**

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_11229cfe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_11229cfe](https://forums.unrealengine.com/u/anonymous_user_11229cfe)\
**Post date:** [June 15, 2019, 7:54pm UTC](https://forums.unrealengine.com/t/assigned-uuserwidget-inside-of-another-widget-is-always-reset-after-compile/450712/3 "2019-06-15T19:54:46Z")

</div>

Thanks for the reply. I tried to change properties to EditDefaultsOnly, but it didn’t work. Regarding the Begin play and constructor, here is my code:

```
void UMyBadWidget::NativeConstruct()
{
	Super::NativeConstruct();

	HorizontalBox = Cast<UHorizontalBox>(GetWidgetFromName(*FString("Container")));

	HorizontalBox->ClearChildren();
	if (Interface.Num() > 0)
	{
		for (int idx = 0; idx < Interface.Num(); ++idx)
		{
			if (auto button = Cast<UUW_Button>(Interface[idx].TypeButton))
			{
				HorizontalBox->AddChildToHorizontalBox(button);
			}
		}
	}
}

```

I see no obvious reason assignment is reset…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_11229cfe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_11229cfe](https://forums.unrealengine.com/u/anonymous_user_11229cfe)\
**Post date:** [June 15, 2019, 9:06pm UTC](https://forums.unrealengine.com/t/assigned-uuserwidget-inside-of-another-widget-is-always-reset-after-compile/450712/4 "2019-06-15T21:06:41Z")

</div>

I think I fixed the issue I had. Here is what I did in the header:

```
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Menu")
		TSubclassOf<UUserWidget> TypeButton;

```

cpp:

```
    HorizontalBox->ClearChildren();
	if (Interface.Num() > 0)
	{
		for (int idx = 0; idx < Interface.Num(); ++idx)
		{
			if (auto button = CreateWidget<UUW_Button>(GetWorld(), Interface[idx].TypeButton))
			{
				HorizontalBox->AddChildToHorizontalBox(button);
			}
		}
	}

```

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [February 25, 2025, 2:06pm UTC](https://forums.unrealengine.com/t/assigned-uuserwidget-inside-of-another-widget-is-always-reset-after-compile/450712/5 "2025-02-25T14:06:17Z")

</div>

Hello guys here is the solution of your all troubles.

If you using designer to edit property like this sadly it wont work.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/f/6/cf6251faaab53c5880c8f286249fb9e92c572d26.png)

See wont, because this is tied to construction script.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/e/75e1806ae3981944f3f345190934ef7ec085e21d.png)

But if you switch to `Graph` and edit details there it will be persistent.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/f/e7fd2de0fee7085694ad46721d623c6ddda91c0e.png)
