Plugin Content can't be accessed by code.

Moved my content to the plugin directory and created a new project. The content is there and works in editor everything linked properly but when trying to access it I can not:

	static ConstructorHelpers::FClassFinder<UBlueprint> RPGHudClass(TEXT("Blueprint'/RPGEngineToolKit/RPGEngineTK/Blueprints/Huds/ModularHud.ModularHud'"));
	if (RPGHudClass.Class != NULL)
	{
		HUDClass = (UClass*)RPGHudClass.Class;
	}

Hey Shoiko-

What do you mean you can’t access it? Are you receiving a compile error? Have you added include statements to the classes you’re trying to access your plugin from? You said you moved content to plugin and then created a new project, is the Plugins folder inside the project directory of your new project? Also, where is the code you posted located? Is that part of your plugin or another class?

Cheers

Sorry let me explain this better.

  1. I created a Plugin using the wizard
  2. Created a custom hud class in the plugin. RPG_MainHud.cpp and the .H are in the main folder of the Plugins\RPGEngineToolKit\Source\RPGEngineToolKit\Private directory.
  3. I verified the Class works in the plugin content folder by making a blueprint class of that custom hud class un the Content folder located in the plugin’s director.
  4. I then created a custom GameMode - RPG_GamePlay_Mode.cpp and the header are in the same directory as the Custom Hud class in the Plugins\RPGEngineToolKit\Source\RPGEngineToolKit\Private directory.
  5. In the content browser of the plugin folder I right clicked the ModularHud blueprint and selected copy reference.
  6. I linked this reference in the constructor of the custom game mode as shown above.
  7. When I run the code at 73% i get a popup stating: Default Property warnings and errors: Error: CDO Constructor(RPG_GamePlay_Mode): Failed to find /RPGEngineToolKit/RPGEngineTK/Blueprints/Huds/ModularHud.ModularHud

Please let me know if this was enough data for this report I can make a mock up project if needed.

I’m not sure I understand what you mean when you say you created a custom hud class in the plugin. Did you manually add a header/source file inside Visual Studio? Did you use the class wizard in the editor to add a class to the project and then move it to the plugin folder? Could you post the setup for your plugin/hud class so that I can try to follow your steps in setting up a reproduction on my end?

Also let me know if right clicking on the .uproject for the project and selecting Generate Visual Studio project files allows the compile to succeed.

I created a class using the wizard. Once it was created I removed the file from the project. Then removed the source files from the source directory to my desktop. I did a Generate Visual Studios project to verify that the new class did not appear in the project anymore. Even under all classes. Next I move the source files to: Plugins\RPGEngineToolKit\Source\RPGEngineToolKit\Private. From there I edited the file and removed the project API references from the class header and replaced the project header include in the Cpp file with #include “RPGEngineToolKitPrivatePCH.h”

Projectfiles:

I then created a BP Class from this object and got a reference to it so i could not load it when gameplay_mode starts:

Everything compiles correctly no errors i only get this when the editor launches which tells me that the engine can not find the blueprint in my content directory in my plugin. I double checked to make sure Has Content is checked in my plugin details:

Default Property warnings and errors: Error: CDO Constructor(RPG_GamePlay_Mode): Failed to find /RPGEngineToolKit/RPGEngineTK/Blueprints/Huds/ModularHud.ModularHud

Was this enough data?

Hi Shoiko,

I am going to see if I can create a project to reproduce the issue that you described. However, the error message that you mentioned seeing is one that I have come across before. The UBlueprint class is intended to be an Editor-only class, and that may be why the Editor is having trouble locating the reference. Try changing

static ConstructorHelpers::FClassFinder RPGHudClass(TEXT("Blueprint'/RPGEngineToolKit/RPGEngineTK/Blueprints/Huds/ModularHud.ModularHud'"));

to

static ConstructorHelpers::FClassFinder RPGHudClass(TEXT("/RPGEngineToolKit/RPGEngineTK/Blueprints/Huds/ModularHud.ModularHud_C"));

This will tell the Editor to look for the generated class that is created when you compile the Blueprint. I will keep working on trying to reproduce the issue that you have described, but if you could give that a try and let me know if it resolves the issue for you, that would be great.

static ConstructorHelpers::FClassFinder < ARPG_MainHud > RPGHudClass(TEXT("/RPGEngineToolKit/RPGEngineTK/Blueprints/Huds/ModularHud.ModularHud_C"));
Added the class specifier, other than that yes this works. So you can get it the BP as the class that it is derived from. That’s nice to know.

I still have not been able to reproduce the issue that you described, but I am glad to hear that my suggestion worked for you. I apologize for any confusion with the missing class specifier, AnswerHub sometimes strips out bits of code that it thinks may be html tags trying to run some other code. I believe I actually used UClass and not ARPG_MainHud in my example, but the result should be the same in this instance.

would you like me to reproduce it for you?

I suspect that this may be just a case of a slightly incorrect class reference. However, if you have a small test project that shows the issue, I would be happy to take a look. It is possible that there may be something else happening.