Newer
Older
app-47-android / Assets / FacebookSDK / Examples / Windows / FBWindowsInitManager.cs
@a_kuznecov a_kuznecov on 22 Jun 2023 1 KB First Commit
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Facebook.Unity;

public class FBWindowsInitManager : MonoBehaviour
{
    public FBWindowsLogsManager Logger;

    public void InitButton()
    {
        if (!FB.IsInitialized)
        {
            FB.Init(InitCallback, OnHideUnity);
        }
        else
        {
            FB.ActivateApp();
        }
    }

    private void InitCallback()
    {
        if (FB.IsInitialized)
        {
            Logger.DebugLog("SDK correctly initializated: " + FB.FacebookImpl.SDKUserAgent);

            FB.ActivateApp();
        }
        else
        {
            Logger.DebugErrorLog("Failed to Initialize the Facebook SDK");
        }
    }

    private void OnHideUnity(bool isGameShown)
    {
        if (!isGameShown)
        {
            // Pause the game - we will need to hide
            Time.timeScale = 0;
        }
        else
        {
            // Resume the game - we're getting focus again
            Time.timeScale = 1;
        }
    }
}