Hi,
I cannot package my game
Cannot open include file: 'Factories/MaterialFactoryNew.h': No such file or directory
but I can run the editor from VS2022 without an issue
this is a simple class generated from the editor, that has AActor as a parent class
#pragma once
#include <string>
#include <Kismet/GameplayStatics.h>
#include <GameFramework/GameModeBase.h>
#include <Factories/MaterialFactoryNew.h>
#include <PackageTools.h>
#include "AssetRegistry/AssetRegistryModule.h"
#include "Materials/MaterialExpressionMultiply.h"
#include "Materials/MaterialExpressionAppendVector.h"
#include "Materials/MaterialExpressionTextureCoordinate.h"
#include "Materials/MaterialExpressionScalarParameter.h"
#include "Components/PointLightComponent.h"
#include "Engine/LevelScriptActor.h"
#include "Components/CapsuleComponent.h"
#include "Engine/World.h"
#include "CoreMinimal.h"
#include "MyCppActor.h"
#include "MyBlueprintFunctionLibrary.h"
#include "BlenderCsvData.h"
#include "WheeledVehicle.h"
#include "MyCppWheeledVehicle.generated.h"
/**
*
*/
UCLASS()
class ROBOTMONK_4_27_API AMyCppWheeledVehicle : public AActor //AWheeledVehicle
{
GENERATED_BODY()
public:
AMyCppWheeledVehicle();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Meshes)
TArray<USceneComponent*> ChildSceneComponents;
//void OnConstruction(const FTransform& Transform) override;
private:
#ifdef WITH_EDITOR
void ImportFromBlender();
UDataTable* AMyCppWheeledVehicle::CsvToTable(FString path);
TArray<FString> GetCSVFile(FString Path);
UStaticMeshComponent* AddStaticMesh(FString name, FString path, FVector location, FRotator rotation, FVector scale);
UTexture* LoadTexture(FString RootPath, FString path);
UPointLightComponent* CreateLight(FString name, FVector Location, float DesiredIntensity);
UMaterial* CreateMaterial(FString MeshName, FString RootPath, FString DiffuseTexturePath, FString AlphaTexturePath, FString EmissiveTexturePath);
#endif
};
what am I missing ?
thanks for your help
3dRaven
(3dRaven)
April 22, 2023, 9:21am
2
MaterialFactoryNew requires the module UnrealEd which is an editor only module.
This thread might be of help regarding getting UnrealEd in a packaged project up and running
Michael, thank you very much for the quick response!
I’ve setup a new module that encapsulates my editor code and I am able to get it to compile. However when I package I still run into the same issue, I thought the ‘Type’:‘Editor’ would take care of the ‘don’t include it when cooking’ part of your suggestion but I’m guessing that is not enough.
Might anyone know how can I make it so that my new editor module is not included when I package the game?
Also try replacing the angled brackets with double quotation marks as in the unreal documentation
include “Factories/MaterialFactoryNew.h”
I know, hence the surrounding of a pragma like this
#if WITH_EDITORONLY_DATA
dynamicCanvas->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
#endif
I should not get these errors
3dRaven
(3dRaven)
April 22, 2023, 12:54pm
4
With the following commented out:
#include "MyCppActor.h"
#include "MyBlueprintFunctionLibrary.h"
#include "BlenderCsvData.h"
#include "WheeledVehicle.h"
and adding #include “Engine/DataTable.h” it compiles just fine and runs the editor (4.27)
Could there be a conflict with something within the commented includes?
Edit:
Perhaps move the load functions to their own static library to make them more reusable?
can you package it ?
I can compile, I just cannot package it
3dRaven
(3dRaven)
April 22, 2023, 7:27pm
6
Yes but i need to add an if statement to cut out editor tool includes
example:
#include <string>
#include "Kismet/GameplayStatics.h"
#include "GameFramework/GameModeBase.h"
#if UE_EDITOR
#include "Factories/MaterialFactoryNew.h"
#include "PackageTools.h"
#endif
edit:
#if WITH_EDITOR works too
also I noticed , as I use VS2022, the editor launches VS2019
where do I change that ?
3dRaven
(3dRaven)
April 22, 2023, 7:50pm
8
ifdef doesn’t work on headers due to it being ignored in pre-compile stages. Use just #if WITH_EDITOR
I uninstalled vs 2019 to stop it launching.
edit:
Just include the includes that are editor only in the if statement (the 2 I mentioned are enough to get a packaged project finish with no errors)
did you check my screen shot ?
I literally put everything in between #ifdef WITH_EDITOR …#endif
I also found where to set the toolchain for the packaging
yet it STILL uses vs 2019
I guess I’ll have to uninstall it too
3dRaven
(3dRaven)
April 22, 2023, 7:59pm
10
Like I mentioned #Ifdef does not work on header includes … use #if
Another post on the forum touches on the subject
You don’t need the defined keyword. If it is not defined it is falsy.
You are doing the equivalent of this in the macro world:
if (I < 5 || 10 || 17)
This is an illegal statement. The code you want is:
#if __cplusplus || UE_GAME || UE_EDITOR || UE_SERVER
1 Like