One of the things we can do when using the Facebook API is to allow our users to log in to the game using their Facebook account. Then, we can use their name and image automatically within our project. The following steps show us how to achieve this:
- Let's first open up our Main Menu level by going to the Project window, open the Assets/Scenes folder, and then double-click on the MainMenu file.
- From there, let's click on the 2D button to go into 2D mode if you haven't done so previously. What we will do is remove the original menu and instead have a button for players to log in via Facebook or play as a guest when the game starts.
- Go to the Hierarchy window, select the Canvas - Scale Physical object, and expand it and the SafeAreaHolder child. Select the Panel child and rename it Menu Options.
- Then, select the Menu Options object in the Hierarchy window and duplicate it by pressing Ctrl + D. Then, rename the newly created Facebook Login...