I want to add extra settings and other stuff to the FOnlineSessionSettings, I know that I can just add them to the Settings array, but I was thinking of making a child class of it and add the new settings there to make it cleaner, but as far as I can tell, there is no option to derive a class from it in the editor, do I have to modify the source to add things there?
Depends on what you mean by “source”. If you mean, “Do I need to modify the C++ code of the project to make a custom FOnlineSessionSettings?”, then the answer is yes. If you mean, “Do I need to download the source engine and modify the c++ code to make a custom FOnlineSessionSettings?”, then the answer is no; you can, but not required. You can not customize or create custom session settings in Blueprints alone.
Here is an incomplete block of code I have for customizing only the SessionSettings of my project:
bool UNWGameInstance::HostSession(TSharedPtr<const FUniqueNetId> UserId, FName SessionName, bool bIsLAN, bool bIsPresence, int32 MaxNumPlayers)
{
// Get the Online Subsystem to work with
IOnlineSubsystem* const OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
//Get the Session Interface so we can call the "CreateSession" function on it
IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();
if (Sessions.IsValid() && UserId.IsValid())
{
SessionSettings = MakeShareable(new FOnlineSessionSettings());
SessionSettings->bIsLANMatch = bIsLAN;
SessionSettings->bUsesPresence = bIsPresence;
SessionSettings->NumPublicConnections = MaxNumPlayers;
SessionSettings->NumPrivateConnections = 0;
SessionSettings->bAllowInvites = true;
SessionSettings->bAllowJoinInProgress = true;
SessionSettings->bShouldAdvertise = true;
SessionSettings->bAllowJoinViaPresence = true;
SessionSettings->bAllowJoinViaPresenceFriendsOnly = false;
SessionSettings->Set(SETTING_MAPNAME, FString("MapName"), EOnlineDataAdvertisementType::ViaOnlineService);
// Set the delegate to the Handle of the SessionInterface
OnCreateSessionCompleteDelegateHandle = Sessions->AddOnCreateSessionCompleteDelegate_Handle(OnCreateSessionCompleteDelegate);
// Our delegate should get called when this is complete
return Sessions->CreateSession(*UserId, SessionName, *SessionSettings);
}
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 20, FColor::Red, TEXT("No OnlineSubsystem found!"));
}
return false;
}
You can check out this article for more information.