Announcement

Collapse
No announcement yet.

map can't save with my UBlueprintFunctionLibrary

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    Click image for larger version

Name:	1.png
Views:	1
Size:	25.3 KB
ID:	1216156


    the PBC is class of the UObject


    Code:
    UCLASS(Blueprintable, BlueprintType)
    class TESTPROJECT_API UPBC : public UObject
    {
    	GENERATED_BODY()
    	
    public:
    
    //.....
    
    };
    and in the blueprint library .h file, i made a function to create the PBC instance.

    Code:
    UCLASS()
    class UNURBSBPLibrary : public UBlueprintFunctionLibrary
    {
    	GENERATED_UCLASS_BODY()
    
    public:
    
    	static UPBC* CreatePBC(int Degree, TArray<FVector> Points);
    
    };
    the .cpp file is

    Code:
    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

    Click image for larger version

Name:	2.png
Views:	1
Size:	30.5 KB
ID:	1216157

    in the level , the PBC is shown

    Click image for larger version

Name:	3.png
Views:	1
Size:	382.3 KB
ID:	1216158

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

    so, how can i fix the problem.

    thanks!!

    #2
    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.
    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment


      #3
      Originally posted by BrUnO XaVIeR View Post
      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?

      thanks

      Comment


        #4
        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

        Comment


          #5
          Originally posted by ZkarmaKun View Post
          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.

          Comment

          Working...
          X