compiler errors - How to create a custom c++ class to use with blueprint -
i trying create custom class can use in blueprints. need class hold player information name , path picture. have made far doesn't compile or build without errors , don't know how fix since have never worked this
header file #pragma once #include "object.h" #include <iostream> #include "playerclass.generated.h" /** * */ uclass() class prototype2_api uplayerclass : public uobject { generated_body() public: uproperty(editanywhere, blueprintreadwrite, category = "switch variables"); string playername; uproperty(editanywhere, blueprintreadwrite, category = "switch variables") string playerteam; uproperty(editanywhere, blueprintreadwrite, category = "switch variables") string picpath; uplayerclass(const fobjectinitializer& objectinitializer); ufunction() void importpic(string picpath); };
.cpp file
#include "prototype2.h" #include "playerclass.h" uplayerclass::uplayerclass(const fobjectinitializer& objectinitializer) : super(objectinitializer) { playername = ""; playerteam = ""; picpath = ""; } void uplayerclass::importpic_implementation(fstring picpath) { }
what found importpic function needs
ufunction(blueprintcallable, category = "import") virtual void importpic(const fstring& path);
and depending on if want class show blueprint variable or able made blueprint class change top heading
uclass(blueprinttype) // blueprint show variable uclass(bleuprintable) // blueprint able made blueprint class
the code built , compiled:
header file
#pragma once #include "object.h" #include "playerclass.generated.h" uclass(blueprinttype) class prototype2_api uplayerclass : public uobject { generated_body() public: uproperty(editanywhere, blueprintreadwrite, category = "player variables") fstring playername; uproperty(editanywhere, blueprintreadwrite, category = "player variables") fstring playerteam; uproperty(editanywhere, blueprintreadwrite, category = "player variables") fstring picpath; uplayerclass(const fobjectinitializer& objectinitializer); ufunction(blueprintcallable, category = "import") virtual void importpic(const fstring& path); };
.cpp -
#include "prototype2.h" #include "playerclass.h" uplayerclass::uplayerclass(const fobjectinitializer& objectinitializer) : super(objectinitializer) { playername = ""; playerteam = ""; picpath = ""; } void uplayerclass::importpic(const fstring& path) { }
Comments
Post a Comment