Components created in C++ do not refresh After compile

Hi want to create some Components in c++ and use them later on in a Blueprint.

I found this Tutorial and did everything like in the Tutorial, I even did Copy & Paste the code, so im 100% sure the Code is correct.

When I compile first time and than create a Blueprint based on the code everything is fine.
But when I want to change something, like removing or adding an component
So I go back to my Code and delete the Parts I dont wanna, or add new code right?

Or other Example I wanna change the name of one Component i edit the String here:

OurParticleSystem = CreateDefaultSubobject(TEXT(“MovementParticles”));

For both I dont get any change after I compile. I need to delete the Blueprint in Editor (After that again in the File Browser cause the editor dont actually deletes it) and when I create a new Blueprint my changes are there.

Is this a Bug?

  • Im using the newest Version 4.14.2
  • My Visual Studio Mode is “Development Editor”.
  • I Compile with the Unreal Compiler Button.

And I have a Question depending to the Tutorial:

Although you can see the asset location of our Static Mesh asset in the code, hard-coding asset paths is not generally considered the best way to load assets. It is usually preferred to create the Component itself in code if the class needs to use it, and then select the assets in the Unreal Editor. However, it is possible to do this directly in code, and could be faster for programmers debugging or building new features.

What does that mean? How can I create the Component without selecting the Asset?

Hey -

The issue with the component not updating in the editor is a known issue that is related to the hot reload process. You can find more information about this here: Unreal Engine Issues and Bug Tracker (UE-30548) . As a workaround, the changes to your code should be reflected once you close/reopen the project. This issue should be fixed when the 4.15 version of the engine is released.

For your second question, what that paragraph is saying is this:

The idea of hardcoding can be seen starting at the line static ConstructorHelpers::FObjectFinder SphereVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere")); though the end of the code block above the note. This is what is referred to as hardcoding, b/c it is the exact path to where that asset is inside the project.

The line that actually creates the component is two lines above at UStaticMeshComponent* SphereVisual = CreateDefaultSubobject(TEXT("VisualRepresentation"));.

The difference between the two is how the component appears when you create a blueprint. In the case of only creating the component (using the CreateDefaultSubobject line) when you select the component inside the blueprint you will see that no static mesh is set. If you hardcode the path to a mesh, then that mesh will be set by default when you create the blueprint.

Cheers

Thanks the workaround is working!
Thanks!

About my other question. When I only create the Component with CreateDefaultSubobject, can I choose and setup the Asset in the Blueprint?

Yes, that is correct