Hello @Fnordcorps ,
The problem isn’t within the UFUNCTION but in the UGeometryCollection itself. It said that undefined error in VS because you need to declare it first like what you are asuming.
What you can do to fix this kind of problem is:
forward declare your undeclared class in the header file like below:
#pragma once
#include "CoreMinimal.h"
#include "X.h"
#include "X.generated.h"
**class UGeometryCollection;**
/**
*
*/
UCLASS()
class Y_API AX : public AActor
By forward declaring class UGeometryCollection in header file, the problem in header file will be fixed, but to use it on .cpp, you need to include it in the .cpp itself (Will do it in step 2)
Include the header file of UGeometryCollection in .cpp file
If you want to know how to look for the header file, you can just google Unreal Engine + your class name (Exm: Unreal Engine UGeometryCollection) and look for this kind of page UGeometryCollection | Unreal Engine Documentation
You will find the include path there
Compile it first. If it’s success then done. BUT some class need more action to do like this UGeometryCollection (btw cpp UMG and AI related also need more action). This error is happening because the module is not included yet in YourProjectName.Build.Cs
Include the module in YourProjectName.Build.Cs.
using UnrealBuildTool;
public class X : ModuleRules
{
public X(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", . . ., "GeometryCollectionEngine" });
}
}
Add GeometryCollectionEngine inside PublicDependencyModuleNames. You can also know the module name by the same method as looking for the include path.