Displaying a Facebook name and profile picture
A good thing to do is to personalize our game to fit our players. So, with that, once the player logs in, we will welcome them and display their image on the screen by following these steps:
- Go to the
MainMenuBehaviour
script once again. From there, we’ll need to add a newusing
statement to display an image and change the text we need in order to use Unity’s UI system and TextMeshPro:using UnityEngine.UI; // Image using TMPro; //TextMeshProUGUI
- We will then need to add two new variables:
[Tooltip("Will display the user's Facebook profile pic")] public Image profilePic; [Tooltip("The text object used to display the greeting")] public TextMeshProUGUI greeting;
These variables will hold the information that we wish to display once we get it from Facebook.
- Afterward, we will update the
ShowMainMenu
function and add some new functions to use:public void ShowMainMenu() { ...