Skip to main content

Add friend list menu - Display friend list - (Unity module)

Last updated on October 24, 2024

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
  • 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
  • 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
  • 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

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.

Friends Menu Canvas Unity Byte Wars 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 Details Menu Canvas Unity Byte Wars friend list

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.

Friend Component Unity Byte Wars friend list

Friend Details Component Unity Byte Wars friend list

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.

  1. Open Byte Wars in Unity.

  2. Open FriendMenuHandler_Starter.cs file and create a new function called GetFriendList.

    private void GetFriendList()
    {
    CurrentView = FriendsView.Default;
    //TODO: replace logwarning with sdk warpper.
    Debug.LogWarning($"GetGet friend list is not yet implemented.");
    }
  3. Update the OnEnable() function with the following code:

    private void OnEnable()
    {
    GetFriendList();
    }
  4. 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