I’ve been trying to use the prebuilt plugin to create an editor mode but I’m not sure I understand where to place new code. It keeps throwing an error and I can’t declare variables or it won’t let me compile. So I have this class that was mostly built except I added the uint32.
class FP23DEdModeToolkit : public FModeToolkit
{
public:
FP23DEdModeToolkit();
/** FModeToolkit interface */
virtual void Init(const TSharedPtr<IToolkitHost>& InitToolkitHost) override;
/** IToolkit interface */
virtual FName GetToolkitFName() const override;
virtual FText GetBaseToolkitName() const override;
virtual class FEdMode* GetEditorMode() const override;
virtual TSharedPtr<class SWidget> GetInlineContent() const override { return ToolkitWidget; }
uint32 TESTINT;
private:
TSharedPtr<SWidget> ToolkitWidget;
};
Inside the .cpp I have tried declaring it to see if ti would work like this:
FP23DEdModeToolkit::FP23DEdModeToolkit()
{
}
void FP23DEdModeToolkit::Init(const TSharedPtr<IToolkitHost>& InitToolkitHost)
{
struct Locals
{
Locals::FP23DCanvas* Canvas;
static bool IsWidgetEnabled()
{
//return GEditor->GetSelectedActors()->Num() != 0;
return true;
}
static FReply OnButtonClick()
{
TESTINT = 5;
return FReply::Handled();
}
static TSharedRef<SWidget> MakeButton(FText InLabel)
{
return SNew(SButton)
.Text(InLabel)
.OnClicked_Static(&Locals::OnButtonClick);
}
};
const float Factor = 256.0f;
SAssignNew(ToolkitWidget, SBorder)
.HAlign(HAlign_Center)
.Padding(1)
.IsEnabled_Static(&Locals::IsWidgetEnabled)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.AutoHeight()
.HAlign(HAlign_Center)
//.Padding(50)
[
SNew(STextBlock)
.AutoWrapText(true)
.Text(LOCTEXT("HelperLabel", "Select some actors and move them around using buttons below"))
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Center)
.AutoHeight()
[
Locals::MakeButton(LOCTEXT("NewLayerLabel", "Add New Layer"))
]
];
FModeToolkit::Init(InitToolkitHost);
}
FName FP23DEdModeToolkit::GetToolkitFName() const
{
return FName("P23DEdMode");
}
FText FP23DEdModeToolkit::GetBaseToolkitName() const
{
return NSLOCTEXT("P23DEdModeToolkit", "DisplayName", "P23DEdMode Tool");
}
class FEdMode* FP23DEdModeToolkit::GetEditorMode() const
{
return GLevelEditorModeTools().GetActiveMode(FP23DEdMode::EM_P23DEdModeId);
}
#undef LOCTEXT_NAMESPACE
It is giving me the following errors:
“TESTINT” undeclared identifier
TESTINT is not a type name, static or enumerator.
Where should I be putting new code? I would like a more useful struct but I get the same error regardless of the type I use. Any help would be appreciated.