Error packaging project with Editor module using UFactory

I was working on custom asset and noticed I’m having some errors with project packaging.
After narrowing down possible errors I’ve came down to the fact having UFactory in Editor module produce error during package


UnrealBuildTool: Error: Couldn't find parent type for 'CustomAssetFactory' named 'UFactory' in current module or any other module parsed so far.

These are modules I have currently.


"Modules": 
    {
      "Name": "TestGame",
      "Type": "Runtime",
      "LoadingPhase": "Default"
    },
    {
      "Name": "CustomToolEditor",
      "Type": "Editor",
      "LoadingPhase": "PostEngineInit"
    }

After narrowing error down I have no editor dependent code in my runtime module, even WITH_EDITOR blocks of code are temporary commented out.

CustomToolEditorModule only contains startup and shutdown methods.



#pragma once

class FDialogueToolEditorModule : public IModuleInterface
{
public:
	virtual void StartupModule() override;
	virtual void ShutdownModule() override;
};

.cpp has basic definition and


IMPLEMENT_GAME_MODULE(FCustomToolEditorModule, CustomToolEditor);

inside

UFactory derived class seems almost empty as well.


#pragma once

#include "CustomAssetFactory.generated.h"

UCLASS()
class CUSTOMTOOLEDITOR_API UCustomAssetFactory : public UFactory
{
	GENERATED_BODY()
		virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
		virtual bool CanCreateNew() const override;
};

Build.cs has UnrealEd module only enabled for editor


        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

        PublicDependencyModuleNames.AddRange(new string] {
            "InputCore",
            "Engine",
            "Core",
            "CoreUObject",
        });
        if (UEBuildConfiguration.bBuildEditor)
        {
            PrivateDependencyModuleNames.Add("UnrealEd");
        }

        PrivateDependencyModuleNames.AddRange(new string] { "TestGame" });


I don’t really understand why editor module (along with UFactory) is getting hooked up when is marked as Editor module. What is happening?

Did you accidently put your editor module as a dependency in your game module, or list it in your game target.cs?

At the time game module is empty and only has engine auto-generated files.
As for game module target.cs it only has “Core”, “CoreUObject”, “Engine”, “InputCore” dependencies added.

Is there anyone who tried to package a game with a custom asset built through UFactory? Problem looks not specific at all and seemingly could be reproduced simply by introducing new asset with UFactory in editor module even though UnrealEd is linked. Looks really weird.

Well you haven’t included Factories/Factory.h in your header for one thing. You may be getting it through the UnrealEd PCH, but you shouldn’t rely on that, you should be including everything you need explicitly.

What build.cs file is that you showed? If it’s for the editor module, there’s no need for the if statement, editor modules will not be processed if it’s not doing an editor build (assuming you having introduced a dependency somewhere as Zeblote says).

Oookay, I’ve actually introduced my editor module into TestGame.Target.cs… Feeling stupid right for pulling up a thread before checking such a basic thing. Thanks, guys.