I want to add a Procedural Mesh Component to my Actor, but I don’t seem to be able to #include it. What do I include to make the C++ code recognize UProceduralMeshComponent?
I did see this suggestion, using a blueprint to do the actual component adding, but that has not worked out well for me. Every time I restart my project, the blueprint forgets it has a ProceduralMeshComponent, and I have to add it again.
I think I may have solved it. By using the component in the blueprint, I was able to locate the class in the content browser. From there, I could create a derived C++ class, which was fully usable without any compiler errors.
I was having the same problem so tried resolving it as you did, by creating and using a subclass of UProceduralMeshComponent, which does the job. I noticed that the header file generated by the editor contains an #include for the component, so I tried copying it into the header for the actor and while VS complains, it does compile! No dummy class needed.
Why the same is not working for me? I wrote #include “ProceduralMeshComponent.h” but code is not compiling with it, also this header file is on Plugins folder of Engine, so probably there is another way to set up this plugin?
A dependency to the ProceduralMeshComponent module is required in one’s ModuleRules build file. For example:
MyGame.Build.cs
public class MyGame : ModuleRules
{
public MyGame(TargetInfo Target)
{
PrivateDependencyModuleNames.AddRange(new string[] {"ProceduralMeshComponent"});
}
}
One can then include ProceduralMeshComponent.h in C++ code:
Apparently, what happens is that once you create a derived class, “ProceduralMeshComponent” automatically gets added to the “AdditionalDependencies” section of the .uproject file, thus allowing the header to be freely included anywhere after that.
1>WARNING : warning : Plugin ‘xxxxx’ does not list plugin ‘ProceduralMeshComponent’ as a dependency, but module ‘xxxxxx’ depends on ‘ProceduralMeshComponent’.
This happens because you have to add the plugin to your uplugin file, in case you are building a plugin not a project using this other plugin: