map can't save with my UBlueprintFunctionLibrary

hi! I made my plugin with UBlueprintFunctionLibrary , but when i put my blueprint class in my map, the map can’t saved.


the PBC is class of the UObject

UCLASS(Blueprintable, BlueprintType)
class TESTPROJECT_API UPBC : public UObject



and in the blueprint library .h file, i made a function to create the PBC instance.

class UNURBSBPLibrary : public UBlueprintFunctionLibrary


	static UPBC* CreatePBC(int Degree, TArray<FVector> Points);


the .cpp file is

UPBC * UNURBSBPLibrary::CreatePBC(int Degree, TArray<FVector> Points)
	UPBC *obj= ConstructObject<UPBC>(UPBC::StaticClass());
	obj->init(Degree, Points);
	return obj;

now i can create PBC in blueprint


in the level , the PBC is shown

but, when i save the map, the message show up like first image.

so, how can i fix the problem.


It complains exactly about what you’re doing;
You have a static function in a blueprint asset… You create an object inside that static function and then you use the ovject inside your level.

The engine can’t save the level, you use in the map objects referenced from outside the game world.
Everything in the game world must Instantiate, this is not what you’re doing in that static function.

so, how i can fix this. what should i do in static UPBC* CreatePBC(int Degree, TArray<FVector> Points), or how can i Instantiate the PBC class?


Hi zhangci,
If your final goal is create a new class to describe curves, you can use an UObject, UActorComponent or AActor and then create a new instance for the editor, c++ is object oriented, There is no reason to have an blueprint function calling statics which includes an “object”. Blueprint function are useful for math process or something repetitive, not for object descriptions.

Additionally you might watch the USplineComponent, maybe you are reinventing the wheel, first check all the possibilities

Thank you ZkarmaKun, now i have changed my idea.