How to add properties to c++ clases via plugin?

As I ask in the title I am interested in create a plugin that adds properties to some c++ classes, currently mi first attempt is to create a new struct variable inside of the static mesh components.

So the cuestion is, can I create a plugin that adds a variable to the static mesh class that I can read and write within the static mesh editor, in static meshes placed in the level, blueprints and so on.

I know i could use workarounds without c++ such as tags, or many other tricks but I realy need to work with it as with a normal variable.

I also know i can edit the source code to create the variables in the source code, I have already done that, but the problem is that compilations takes to long and I can not export that behaviour individually as i can with plugins.

So is really important to make it with plugins, also is there is any tutorial, please share it so I can follow it. Thanks

Hi Doc.gdi,

You can use UAssetData - just create a new Class derived from it and add your data there:

Thanks for your answer but I don’t think that’s what im looking for, I know that I can create a sub class from any object but then I would not have the editor menu. I’ll explain a little better what I want.

I want to add a struct variable to the staticMesh class, in that struct there are some parameters for penetration of the bullets, add the posibility of scale the main penetration resistance based on the direction, or if the resistance value scales with the world scale of the mesh.

So the idea is that I can change all those values within the mesh editor, and not by going one by one in the scene changing the values of every single instance, and without creating classes for each static mesh with it’s values. Just open the mesh editor and be able to change those values

Yes the UAssetData is more for individual settings (You SubClass the UAssetData class, UActorComponent has an array of UAssetData pointers that contain your subclassed ones - it doesn’t subclass the actor at all, similar to Tags)

You can still use it, but you would have to have a pointer to the static mesh (that contains the UAssetData) and read your struct from that reference - if you’re just dragging the mesh onto your level, it clears those UAssetData lists from the StaticMesh Components used by the actors.

From the sounds of what you’re doing though - you’d be wrapping the StaticMesh in a Blueprint? It could work well with the UAssetData system if you are, you can edit your struct in the StaticMesh Editor, and all your Blueprints that reference that StaticMesh will get the updated struct:

Other options rather than build the data into the StaticMesh: You could have a global Map with the StaticMesh Reference as the Key and a struct with your data in as the Value? Or a DataTable - that is a common way of doing it too.

The idea is to directly drag and drop the static mesh into the level, because I am not the level designer and he has no idea of programming, so if he can not drag and drop elements as any other the project speed would slow down. For now I been able to insert the struct via the source code, so when I drag and drop the mesh onto the level already have the struct, but as I can see there’s no way to add variables to the class by plugins, thats OK I did not expect it was possible but at least I asked.

The idea of using a global Map variable seems ok with me, but I still prefer to edit within the editor, so really the topic is solved and I’ll mark your answer as solution when last question is solved.

But for go for the last thing I would like to know how to add to the mesh editor the possibility of setting the default values of the struct. I guess is a bit complicated, but if you could please explain it or if you know of a documentation or tutorial that shows how to do it (even if is other editor insted of the static mesh editor) i will be able to complete the task.

Thank you again for all the help

You can add Toolbar buttons and menus, or add a details like pane to the editor, you just hook the editors Open and inject your code, Here’s a tutorial on it:

http://wlosok.cz/editor-plugins-in-ue4-3-toolbar-button/

Here’s a link to the Details Panel info: