Getting Started with the Facebook Unity SDK

This guide provides step-by-step instructions to implement the Facebook Unity SDK.

The Facebook Unity SDK works with Unity 5.0 and above.

Before You Start

You will need the following:

Get Your Facebook App ID

In your app dashboard under Settings > Basic, copy your App ID.

Add the SDK to your Unity project

Step 1: Create a new project in the Unity Editor.

Create an new Unity project

Step 2: Download the latest Facebook SDK. Unzip this package after downloading. The code for this sample project will be included.

Step 3: In the Unity editor, select Assets > Import Package > Custom Package… Navigate to the directory where you downloaded the Facebook for Unity SDK and select FacebookSDK.unitypackage. Note: You will need to remove previously integrated Facebook SDK packages before importing a newer version.

Import package

Step 4: Import all assets in the package.

Import package

Step 5: Save your project. A post-build script will add a Facebook menu item to the Unity editor. If you don't see this, check your build for compilation errors and try building again.

Step 6: In the Unity editor, select Facebook > Edit Settings.

Facebook Unity settings

In the Inspector FacebookSettings, paste in your Facebook App ID.

Facebook Unity settings

Step 7: In your app dashboard under Settings > Advanced, copy your Client token.

Paste it beneath your Facebook App ID in the Unity Editor.

Run the sample project

Step 1: In the Project panel, under Assets > FacebookSDK, you will find all the files for the Facebook Unity SDK. Open the folder titled Examples. Double click on the MainMenu scene to open the sample project menu.

Open the sample project

Step 2: In the Unity editor, select File >Build Settings.

Unity Build Settings

Select all the Unity Scenes in the Examples folder and drag them over to the Build Settings panel. Drop them in Scenes In Build. Drag the MainMenu scene to the 0 position, the first position in the list.

Unity Build Settings

Step 3: Enter Play mode to run our example code for a simple demo of the Facebook SDK functionality.

Unity Play ModeFacebook Unity example

Note: The Unity editor environment offers limited functionality, and all the functions are stubbed. It is safe to ignore any warnings or errors regarding the inability of the example game to reach Facebook.

Next Steps

After the basic configuration of the Unity SDK refer to the guides below to continue with platform specific configurations.