Variables changed in C++ OnConstruction not editable in Details Panel

Hey guys,

I actually have 2 issues here:

  1. when I Change a Value of a Member Variable, which is marked as EditAnywhere, in C++ OnConstruction this Value is not editable anymore in the Details Panel of an instanced Blueprint which is placed in World. (In BP Viewport they can be edited)

  2. The next Problem is that when I Change Values in OnConstruction Script the values are not updated in the Viewport Details Panel of a Blueprint

I don’t know if this is intended so I marked this question as a Bug Report just to get sure.

Thanks in advance for you help :slight_smile:

Hey -

Can you provide the code you’re using to test this? In my header file I declare the OnConstruction function void OnConstruction(const FTransform& Location) override; and define a variable UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Test) float Seen;

In the source file I define the OnConstruction() function:

void AMyActor::OnConstruction(const FTransform& Location)
{
	Seen += .5;
}

When I add a BP instance of this class into the level, I see the value of Seen updating as I move the actor and I’m able to directly set the value in the details.

Additionally, can you explain why you need to change the value of a variable on construction? If you are trying to set a default value for the variable, it would be best to do this in the constructor rather than in the OnConstruction function. This will set the value once rather than continually change the value as the actor is manipulated in the viewport.

Hey :slight_smile:
I thought EditAnywhere would include BlueprintReadWrite :confused:
Ok first Issue solved :slight_smile:

But the second one is still a Problem for me.
I can live with it, but it would be a cool Feature.
But I just saw that the question above wasn’t right.
Maybe I should give more context to this.

Let’s say we have a Custom Component derived from BoxComponent
In this Component we have a Variable Width and Height to control the BoxExtent of the BoxComponent. The Component has also an Update() Method to update its width and height.
Next we will create a Blueprint Actor which owns this Component.
In the Construction Script we call Update from the Component.
Everytime something changes the Width and the Height will be updated correctly, but in the Blueprint Editor the Value won’t Change at all.

I hope you can understand my issue.
My english isn’t the best :stuck_out_tongue:

I believe I understand what you’re saying, however I’m not sure how to test it without more information. Can you provide the code for the update function? Also, are Height and Width set with the UPROPERTY macro and the same specifiers mentioned earlier (EditAnywhere, BlueprintReadWrite)?

Ok
The best Option would be if I explain the usage of my attempt.

First:
I want to create a User Interface Template so Designers can easily create UI
First I thought about using UMG but unfortunately I could not get the Interaction to work because of the switching from Game Input to UI Input Mode.
The “Game” uses the first Person template provided by you guys.

My attempt:
I created a base class UIElement which derives from USceneComponent which has an Update Method which just Sets the Width and the Height. This Function is virtual and can be overriden by the subclasses of UIElement (For Example:
UIButton overrides SetWidth and additionally corrects the BoxExtent of the BoxComponent UIButton creates (Theres also an Issue because Child Components won’t work correctly when initialized in the constructor of a Component. I hope you can help me too, with that :D. Component Hierarchy Issue)
The Width and Height Properties have the Specifiers EditAnywhere and BlueprintReadWrite.
Important Base classes of UIElement are:
InteractableUIElement (for example UIButton)
and LayoutUIElement:
LayoutUIElement are for examples HBoxes and VBoxes.

HBoxes align the UIElement which are attached to them horizontally and set the width and the height in dependency of their own.
simple example:
UIButton wants 50% Width

void UHBox::Update()
{
    //...
    UIButton->SetWidth(this->Width*0.5f);
    //...
}

void UUIButton::SetWidth(float NewWidth)
{
    Super::SetWidth(NewWidth);
    BoxCollision->SetBoxExtent(FVector(1, Width, Height)*0.5f);
}

I hope this is the Information you Need to help me :slight_smile:

Now I’m not sure what you’re doing. I created a BoxComponent class with Height/Width/Length variables and made a call to SetBoxExtent my function. When I call that function in my blueprint construction script any changes to the blueprint will update the box extent with the current value of the three variables. This includes if I change the value of the variables, the box updates its extent instantly. If possible, could you provide a sample project with the setup you have so far so that I can see what your setup looks like?

The BoxExtent will be updated like expected.
Internally the Values will update and visually everything Looks fine.
But the Values in the Details Panel won’t Change.
Long Story short:
The Width and Height Show false Values:
Here a Picture:

These values never Change in the Details Panel although they have a different value in my c++ code.


After further tests, I am still seeing the detail panel values updating after compiling within Visual Studio. If you are seeing this in both 4.11 and 4.12, can you provide a copy of the project with this issue so I can try to investigate locally?

Hey ,
unfortunately I cannot publish or Hand over the code. :confused:
The only Thing I can do is to provide you with more Information.

Thanks so far for your help

Sorry for the delayed response, I’ve tested this a few more times and have not been able to reproduce the variables not updating in the blueprint. Can you let me know if this is still occurring and if it is only occurring with the height and width variables or with other variables as well?

Hey .
No problem.
This happens with all variables of my Component.
Maybe I can provide you my source code but I can’t publish it here.
Can you give me an Email Adress or something?
I think I can give it to you today or Monday then.

Thanks

If you’re able to upload the files/project, you can send me a PM on the forums with the download link.

Hi ,

We have not heard back from you in a few days and I did not receive a project on the forum, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.