Getting Started Facebook for Unity

The Facebook SDK for Unity works with Unity 5.0 and above.

No matter what your target platform is, you'll need to start with creating a Facebook App ID for your game. The App ID is used to configure your Facebook SDK within Unity.

If you've never developed a game with Facebook before, or have never registered as a developer, follow the Developer Onboarding Guide first.

Create your app on Facebook

Step 1: If you do not already have a Facebook App ID for your app, you should create one:

Create a New App

 
Step 2: Once completed, you'll see your app's Basic Settings page. Here you can find your App ID, which is required within your Unity game's configuration, in order to integrate with Facebook.

Facebook App Settings

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 for Unity from our Downloads page. Unzip this package after downloading. The code for this sample project will be included.

Step 3: In the Unity Editor, select from the menu 'Assets', 'Import Package' and then 'Custom Package…'. Navigate to the directory where you downloaded the Facebook for Unity SDK and select FacebookSDK.unitypackage.

Import package

Step 4: Import all of the assets in the package.

Import package

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

Step 6: Select 'Edit Settings' from the 'Facebook' menu.

Facebook Unity settings

The inspector will show "FacebookSettings". In the input box under 'App Id:', paste in your Facebook App ID, found as described in the steps above.

Facebook Unity settings

Run the sample project

Step 1: In the Project panel, under 'Assets', there is a folder named 'FacebookSDK'. Inside this folder are all the files for the Facebook SDK for Unity. 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 from the menu 'File' and then 'Build Settings'.

Unity Build Settings

Select all the Unity Scenes in the 'Examples' folder from above and drag them over to the Build Settings Panel and drop them in the 'Scenes In Build' area. Drag the 'MainMenu' scene to be in order position 0 as below.

Unity Build Settings

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

Unity Play ModeFacebook Unity example

Note: The Unity Editor environment offers limited functionality, and all the functions are stubbed. You may receive warnings and errors regarding the game's inability to reach Facebook and read assets from us; it's safe to ignore them.

Platform Specific Next Steps

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

Select Your Platform:

iOSAndroidFacebook Canvas