I’m trying to expand the ShooterGame’s ShooterEntry to allow players to set the name of their server.
My naive attempts are as follows:
ShooterMainMenu.cp
void FShooterMainMenu::Construct(APlayerController* _PCOwner, AShooterGame_Menu* _SGOwner)
{
...
// HOST menu option
MenuItem = MenuHelper::AddMenuItem(RootMenuItem, LOCTEXT("CreateServer", "Create Server"));
// submenu under "host"
MenuHelper::AddMenuItemSP(MenuItem, LOCTEXT("ServerName", "Server Name"), this, &FShooterMainMenu::OnUISetServerName);
TSharedPtr<SEditableTextBox> HostNameEditTextItem;
MenuHelper::AddCustomMenuItem(MenuItem, SAssignNew(HostNameEditTextItem, SEditableTextBox));
...
}
This compiles but crashes on ‘check( IsValid() );’ inside SharedPointer.h when I highlight the ‘Create Server’ option of the menu
/**
* Converts a shared pointer to a shared reference. The pointer *must* be valid or an assertion will trigger.
*
* @return Reference to the object
*/
// NOTE: The following is an Unreal extension to standard shared_ptr behavior
FORCEINLINE TSharedRef< ObjectType, Mode > ToSharedRef() const
{
// If this assert goes off, it means a shared reference was created from a shared pointer that was NULL.
// Shared references are never allowed to be null. Consider using TSharedPtr instead.
check( IsValid() );
return TSharedRef< ObjectType, Mode >( *this );
}
Still haven’t built up a great mental model of slate so I’m going to keep at it and hopefully figure this out but was hoping someone might give me some pointers.