Add friend list menu - Display friend list - (Unity module)
What's on the menu
In this tutorial, you will learn how to prepare the user interface (UI) you will use to display a player's friend list. The files are available in the Resources section and consist of the following:
- FriendMenuCanvas_Starter: You will use this to display the friend list.
- CS file:
Assets/Resources/Modules/FriendEssentials/Scripts/UI/FriendMenuHandler_Starter.cs
- Prefab file:
Assets/Resources/Modules/FriendEssentials/Prefabs/FriendList/FriendMenuCanvas_Starter.prefab
- CS file:
- FriendDetailsMenuCanvas_Starter: You will use this to display individual friend details.
- CS file:
Assets/Resources/Modules/FriendEssentials/Scripts/UI/FriendDetailsMenuHandler_Starter.cs
- Prefab file:
Assets/Resources/Modules/FriendEssentials/Prefabs/FriendDetails/FriendDetailsMenuCanvas_Starter.prefab
- CS file:
- FriendComponent: You will use this to display additional friend information, such as the display name, avatar, and option buttons.
- CS file:
Assets/Resources/Modules/FriendEssentials/Scripts/UI/FriendEntryComponentHandler.cs
- Prefab file:
Assets/Resources/Modules/FriendEssentials/Prefabs/FriendList/FriendComponent.prefab
- CS file:
- FriendDetailComponent: You will also use this to display additional friend information, such as the display name, avatar, and option buttons.
- Prefab file:
Assets/Resources/Modules/FriendEssentials/Prefabs/FriendDetails/FriendDetailComponent.prefab
- Prefab file:
Take a look at more details on how these menus are constructed.
Friends Canvas
Below is the preview of the FriendMenuCanvas_Starter
UI prefab. This prefab contains a list to display the friend list.
Friend Details Canvas
Below is the preview of the FriendDetailsMenuCanvas_Starter
UI prefab. This prefab contains components to display individual friend information, such as display name and avatar image.
Friend Component
Below is the preview of the FriendComponent.prefab
and FriendDetailsComponent.prefab
. These UI components display friend information, such as display name and avatar.
What's in the Starter Pack
A C# script called FriendMenuHandler_Starter.cs
has been created for you which already includes some predefined code. You can refer back to Search for players for more details on this class.
Ready the UI
In this section, you will learn how to prepare the UI.
Open Byte Wars in Unity.
Open
FriendMenuHandler_Starter.cs
file and create a new function calledGetFriendList
.private void GetFriendList()
{
CurrentView = FriendsView.Default;
//TODO: replace logwarning with sdk warpper.
Debug.LogWarning($"GetGet friend list is not yet implemented.");
}Update the
OnEnable()
function with the following code:private void OnEnable()
{
GetFriendList();
}Play the game in the Unity Editor and, if the implementation was successful, you will be able to navigate to Social > Friends and the logs you added earlier will appear.
Get friend list is not yet implemented.
Resources
- The files used in this tutorial are available in the Unity Byte Wars GitHub repository.
- Assets/Resources/Modules/FriendEssentials/Scripts/UI/FriendMenuHandler_Starter.cs
- Assets/Resources/Modules/FriendEssentials/Prefabs/FriendList/FriendMenuCanvas_Starter.prefab
- Assets/Resources/Modules/FriendEssentials/Scripts/UI/FriendDetailsMenuHandler_Starter.cs
- Assets/Resources/Modules/FriendEssentials/Prefabs/FriendDetails/FriendDetailsMenuCanvas_Starter.prefab
- Assets/Resources/Modules/FriendEssentials/Scripts/UI/FriendEntryComponentHandler.cs
- Assets/Resources/Modules/FriendEssentials/Prefabs/FriendList/FriendComponent.prefab
- Assets/Resources/Modules/FriendEssentials/Prefabs/FriendDetails/FriendDetailsComponent.prefab