How to add UPROPERTY dynamically?

Could you be a little more specific as to what you are trying to do? It sounds like you are wanting to assign the variable.

Ohh like this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Strings)
FString MyStringProperty;

This make it so the string will appear in the editor. You can set it to whatever you like in there, also blueprints will be able to edit it at run time.

In normal case i can do:

UPROPERTY()
FString MyStringProperty;

But i need:

// not uproperty
FString MyStringProperty;
void AddMyStringToPropertiesOfThisActor()
{
    ???
}

how to?

I am trying to make MyStringProperty visible/editable in DetailPanel inside Editor for MyActor.

yes, but without using UPROPERTY. Using only C++ functions.

nice idea with TArray, but i was hoping to add MyStringProperty directly as single property…

UPROPERTY works with UBT generated stuff, XXX.generated.h"
1, it need generate stuff before compile,
2, it should been compiled by c++ compiler.

So, you can not change a c++ nature variable become to a uproperty.
But you can make a TArray UPROPERTY, and dynamic add elements in runtime.

Cheers
Omega

You can if you put your custom property inside a USTRUCT and then mark the variable inside that struct as a UPROPERTY. This way you can dynamically spawn stuff from C++ (even outside of the contructor and at designtime) and still mark it as a UPROPERTY. This is what I currently use.

Be aware though that this workaround in some cases may cause side-effects (possible UE4-bugs) in specific cases.

I however do wonder why the UE4-devs limited us like that in this regard.