Hi,
I want to create a (gameplay) module containing a number of generated USTRUCTs which later can and will be accessed via the Editor in Blueprints. Creating those USTRUCTs in the primary module works as expected, but as soon as I move them to another module, the editor crashes on startup (the module’s dll builds successfully though).
When starting the Editor via VS, it breaks with the following error message:
\Runtime\CoreUObject\Private\Templates\Casts.cpp(11)
Fatal error: Cast of NULL to Package failed
UE4Editor_Communication!CastChecked<UPackage>() + 174 bytes [\4.4\engine\source\runtime\coreuobject\public\templates\casts.h:30]
UE4Editor_Communication!Z_Construct_UPackage_Communication() + 102 bytes [\unreal projects\moduletest\intermediate\build\win64\inc\communication\communication.generated.cpp:57]
UE4Editor_Communication!FRespTest::StaticStruct() + 21 bytes [\unreal projects\moduletest\intermediate\build\win64\inc\communication\communication.generated.cpp:18]
UE4Editor!FEngineLoop::LoadStartupModules() + 71 bytes [\engine\source\runtime\launch\private\launchengineloop.cpp:1772]
The interesting thing is, if I convert everything to a proper UCLASS (e.g. inheriting from AActor), the editor starts up just fine. I can also create a Blueprint based on that UCLASS (appriopriatly defined in the C++ code, of course). I am not sure whether it is an issue in my module setup or a bug in the engine.
Thanks in advance!
The USTRUCT in question
/Source/Communication/Public/RespTest.h
#pragma once
#include "RespTest.generated.h"
USTRUCT(BlueprintType)
struct FRespTest
{
GENERATED_USTRUCT_BODY()
UPROPERTY(BlueprintReadWrite, Category = "MyModule")
int32 SomeValue;
};
Module Setup (Reproduction)
What I have done to create the module Communication based on (the documented version seems rather old and confusing):
- What is the proper method for extending the Editor Engine? - C++ - Epic Developer Community Forums (accepted answer)
- How can I get a Gameplay Module to load? - Programming & Scripting - Epic Developer Community Forums
Directory structure:
- Source
- Communication
- Public
+ RespTest.h
- Private
+ Communicaton.Build.cs
+ Communication.h
+ Communication.cpp
- ModuleTest (primary module)
Copied the ModuleTest.Build.cs, ModuleTest.h and ModuleTest.cpp to Communication/ and renamed all occurences of ModuleTest to Communication (filenames and filecontent).
Content of Communication.cpp:
#include "Communication.h"
IMPLEMENT_MODULE( FDefaultGameModuleImpl, Communication);
I also changed the following files:
Source/ModuleTest.Target.cs
[...]
OutExtraModuleNames.AddRange( new string[] { "ModuleTest" } );
OutExtraModuleNames.AddRange( new string[] { "Communication" } );
[...]
Source/ModuleTestEditor.Target.cs
[...]
OutExtraModuleNames.AddRange( new string[] { "ModuleTest" } );
OutExtraModuleNames.AddRange( new string[] { "Communication" } );
[...]
/ModuleTest.uproject
[...]
"Modules": [
{
"Name": "ModuleTest",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "Communication",
"Type": "Runtime",
"LoadingPhase": "Default"
}
[...]