Popup comments from another variable to another variable?

Hi, How can I do it in Unreal to declare one comment for many variables instead of writing repeating the comment for every variable when they are in one category?

//@{
/** same comment for all variables*/
Float MyFloat;
Int MyInt;
FString MyString;
//@}

Reference Question StackOverflow

Your comment above the variable should describe it, and if it’s a different variable, it should be described differently.

1 Like

so this is not possible to declare one comment for many variables if they are for the same task?

well you can write whatever you want in the comments, but the editor will only consume the comment immediately preceeding the variable and use it as a tooltip.

I assumed you wanted to repeat the same tooltip for each variable, which, no. Bad style practice.

1 Like

yes this is what I want. but sadly this is not possible without doxygen.

If the variables are that tightly related, you probably should make a struct for them to indicate that.

and then accessing the struct variable mystruct.myvariable is another problem :smiley:

If it even works you could try:

#define SOMEMACROCOMMENT "This is a tooltip"

UPROPERTY(meta = (ToolTip = SOMEMACROCOMMENT))
  float MyProperty = 1.f;

But I have never been in a situation I’d need a reusable comment. That might point at a bad code style. Also structs should just be used as data container for “any” purpose, as generic as the code allows. So it’s hard to add a single comment / tooltip to a struct.

2 Likes

this will only works for global variables defined in .h class , and what about variable s defined under the function definition? or local variables in .cpp file

They are comments. They are meant for you and other people in the code to read. Only the comments in the .h files are consumed by the editor.

global variables are not defined in a class, those are class properties. global variables are defined outside of all classes. they are, global.

variables inside a function are local variables.

1 Like

I mean we can’t use uproperty if we want to declare variable in .cpp ?

You don’t declare in cpp, you define in cpp

1 Like

yes this is what I want but i don’t know which plugin will help me

You are way overthinking something. :slight_smile: There’s no point to uproperty inside a function, it wouldn’t do anything useful. The only special handling of comments is to put them in as tooltips in the editor, which only occurs on things declared in class and struct templates.

1 Like

well I will use doxygen then, its not comfirt but i have no other hope

overall, if you want to write the same comment for multiple pieces, there are probably better ways to do whatever you’re doing.

what are you trying to achieve? why would you run doxygen on your unreal code?

1 Like

I still want this thing, it will very useful for me

Sorry, now I got you. Doxygen is a documentation generator and is confusing in the question the code you included is from doxygen . What you have asked, popup comments from another line, is impossible. The editor in VS shows only variable declarations and upper line comments.

hope it helps
cheers!

1 Like

i should re title the question, thank you for correcting me

this will even help little but yes at least will help, thank you for the solution Sir :slightly_smiling_face: