ログインメニューを追加する - Steam でログインする - (Unity モジュール)
This tutorial module does not apply to WebGL builds due to limitations in Steamworks.
What's on the Menu
For this module, you will use the LoginMenu_Starter that you configured in the previous Login with Device ID module. This menu consists of the following files:
- LoginMenu_Starter: A C# class used to display the login menu.
- C# file:
/Assets/Resources/Modules/AuthEssentials/Scripts/UI/LoginMenu_Starter.cs
- Prefab file:
/Assets/Resources/Modules/AuthEssentials/Prefabs/LoginMenu_Starter.prefab
- C# file:
In the LoginMenu_Starter
class, you will find the following button component. You will use this button to send a login request using single platform authentication, such as Steam:
[SerializeField] private Button loginWithSinglePlatformAuthButton;
Byte Wars will configure this button dynamically at runtime to display the single platform authentication login option. Since you will implement Steam as the single platform auth method, this button will be automatically bound to the following function in the SinglePlatformAuthWrapper_Starter
class:
private void OnLoginWithSteamButtonClicked() { }
The SinglePlatformAuthWrapper_Starter
class is a wrapper you will use to send the Steam platform token to log in to AGS. This process will be explained in more detail in the next section. The class is defined in the following file:
- C# file:
Assets/Resources/Modules/SinglePlatformAuth/Scripts/SinglePlatformAuthWrapper_Starter.cs
Ready the UI
In this section, you will prepare the UI for the single platform authentication integration using Steam.
Open the
SinglePlatformAuthWrapper_Starter
class and add the temporary code below to change the login menu to the loading state. You will later replace this with the actual login request.private void OnLoginWithSteamButtonClicked()
{
LoginMenu_Starter loginMenu = MenuManager.Instance.GetCurrentMenu() as LoginMenu_Starter;
if (!loginMenu)
{
return;
}
loginMenu.OnRetryLoginClicked = OnLoginWithSteamButtonClicked;
loginMenu.WidgetSwitcher.SetWidgetState(AccelByteWarsWidgetSwitcher.WidgetState.Loading);
}Go back to the Unity Editor. Navigate to
Assets/Resources/Modules/SinglePlatformAuth
and open theSinglePlatformAuthAssetConfig.asset
. Make sure the module is activated in Starter Mode by checking both theIs Active
andIs Starter Active
checkboxes.Return to the Unity Editor and play the game. You will see the Login with Steam button appeared.
Resources
The files used in this tutorial section are available in the Unity Byte Wars GitHub repository.