Editor module is getting cooked when cooking content for Client or Server target

Hello everyone,

I have an Unreal Engine plugin that has functionality for the editor as well as functionality for game runtime, in my plugins StartupModule() function, I am encapsulating code that essentially writes to a config .ini file and adds a new tool menu button for the unreal editor.

This is wrapped in #if WITH_EDITOR

When packaging my project, the build commands succeeds but the cook commands fails with this error:

UATHelper: Packaging (Windows): LogOutputDevice: Warning:
UATHelper: Packaging (Windows): Script Stack (0 frames) :
UATHelper: Packaging (Windows): LogWindows: Error: appError called: Assertion failed: IsValid() [File:E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 1071]
UATHelper: Packaging (Windows): LogWindows: Error: begin: stack for UAT
UATHelper: Packaging (Windows): LogWindows: Error: === Critical error: ===
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error: Assertion failed: IsValid() [File:E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 1071]
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff9f3703f89 UnrealEditor-Slate.dll!FSlateApplication::Get() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Slate\Public\Framework\Application\SlateApplication.h:256]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff9f3766a49 UnrealEditor-Slate.dll!FUIAction::FUIAction() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Slate\Private\Framework\Commands\UIAction.cpp:18]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff9c65d1312 UnrealEditor-BCClientPlugin.dll!FBCClientPlugin::StartupModule() [E:\UnrealProjects\MyProject\Plugins\MyPlugin\Source\MyPlugin\Private\MyPlugin.cpp:57]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff9f48dec71 UnrealEditor-Core.dll!FModuleManager::LoadModuleWithFailureReason() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Core\Private\Modules\ModuleManager.cpp:617]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff9f443d394 UnrealEditor-Projects.dll!FModuleDescriptor::LoadModulesForPhase() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Projects\Private\ModuleDescriptor.cpp:696]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff9f44539b4 UnrealEditor-Projects.dll!FPluginManager::TryLoadModulesForPlugin() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Projects\Private\PluginManager.cpp:2078]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff9f443d0bf UnrealEditor-Projects.dll!FPluginManager::LoadModulesForEnabledPlugins() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Projects\Private\PluginManager.cpp:2154]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6016f7ae0 UnrealEditor-Cmd.exe!FEngineLoop::LoadStartupModules() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4181]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6016fada5 UnrealEditor-Cmd.exe!FEngineLoop::PreInitPostStartupScreen() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:3523]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6016f32e8 UnrealEditor-Cmd.exe!GuardedMain() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Launch\Private\Launch.cpp:154]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6016f35ca UnrealEditor-Cmd.exe!GuardedMainWrapper() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:107]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff6016f6350 UnrealEditor-Cmd.exe!LaunchWindowsStartup() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:244]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff601707d54 UnrealEditor-Cmd.exe!WinMain() [E:\UE5\UE_5.1_Source\UnrealEngine-release\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:282]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ff60170a2da UnrealEditor-Cmd.exe!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffa742a7344 KERNEL32.DLL!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error: [Callstack] 0x00007ffa74fa26b1 ntdll.dll!UnknownFunction []
UATHelper: Packaging (Windows): LogWindows: Error:
UATHelper: Packaging (Windows): LogWindows: Error: end: stack for UAT

The line referenced in MyPlugin.cpp:55 is this:

NewSection.AddMenuEntry(
            FName("My widget"),
            FText::FromString("My widget"),
            FText::FromString("Open my utility widget"),
            FSlateIcon(),
            FUIAction(
                FExecuteAction::CreateRaw(this, &FMyPlugin::MenuCommand)
            ),
            EUserInterfaceActionType::Button,
            FName("My Utilities"));

There is a reference to a MenuCommand function, its’ contents are also wrapped in #if WITH_EDITOR like so:

    void MenuCommand()
    {
#if WITH_EDITOR
        //my code
#endif
    }

All of this code is wrapped in #if WITH_EDITOR - I even tried #if WITH_EDITOR && WITH_EDITORONLY_DATA, didn’t fix it.

I also tried cleaning my saved and intermediate folders, that didn’t fix it either.

I also checked Exclude editor content when cooking in project settings, didn’t fix it.

But for some reason the cooking process is still picking this up, why?

Are you sure you have the correct structure for your plugin? Did you generate the base plugin with the wizard or write it by hand? Perhaps you are missing the header wrapper?

it should look something like this

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "Modules/ModuleManager.h"

class MyPluginModule : public IModuleInterface

{

public:

/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};

Thanks for the response, I do believe I have the correct structure.

Instead of inheriting directly from IModuleInterface I have a separate class, named IMyPlugin which inherits from IModuleInterface and my FMyPlugin class inherits from IMyPlugin

IMyPlugin.h

#pragma once

#include "Modules/ModuleManager.h"

/**
 * The public interface to this module.  In most cases, this interface is only public to sibling modules
 * within this plugin.
 */
class IMyPlugin : public IModuleInterface
{

  public:
    /**
     * Singleton-like access to this modules interface.  This is just for convenience!
     * Beware of calling this during the shutdown phase, though.  Your module might have been unloaded already.
     *
     * @return Returns singleton instance, loading the module on demand if needed
     */
    static inline IMyPlugin &Get()
    {
        return FModuleManager::LoadModuleChecked<IMyPlugin>("MyPlugin");
    }

    /**
     * Checks to see if this module is loaded and ready.  It is only valid to call Get() if IsAvailable() returns true.
     *
     * @return True if the module is loaded and ready to use
     */
    static inline bool IsAvailable()
    {
        return FModuleManager::Get().IsModuleLoaded("MyPlugin");
    }
};

MyPlugin.cpp

class FMyPlugin : public IMyPlugin
{
public:

    /** IModuleInterface implementation */
    virtual void StartupModule() override
    {
#if WITH_EDITOR 
          //my code
#endif
    }

    virtual void ShutdownModule() override
    {
#if WITH_EDITOR 
          //my code
#endif
    }

};
IMPLEMENT_MODULE(FMyPlugin, MyPlugin)

This was all working, until I added code that I needed to only run in the editor, then it won’t cook content for my platform (Windows) anymore.

Edit:
I just realized, the module type I am working with is Runtime - Could this be the reason why it is still cooking that code despite it being contained in #if WITH_EDITOR ?

I will try to create a new module, put my editor specific code in there and make it an Editor type module, I will report back if this works.

Tried making a separate module and made it’s type Editor and that still didn’t work, same errors when cooking. I also tried setting the module type to UncookedOnly and that also didn’t work.

Basically, when cooking content I just don’t want this module to be cooked at all if we are cooking for the client or server target. But for some reason it is still getting picked up by the cook content command.

Any guidance is greatly appreciated

I fixed the issue, in my .uplugin file I changed the “Type” of my module to EditorNoCommandlet

I also added

"BlacklistTargets":[
        "Game",
        "Server",
        "Client"
]

to my module definition, now it isn’t getting picked up by the cook command and it is running when the editor launches as intended.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.