// Start is called before the first frame update
    void Start()
    {
#if UNITY_PS4
        try
        {
            Sony.NP.Main.OnAsyncEvent += OnAsyncEvent;
            Sony.NP.InitToolkit init = new Sony.NP.InitToolkit();
            init.SetPushNotificationsFlags(Sony.NP.PushNotificationsFlags.NewInGameMessage |
                                           Sony.NP.PushNotificationsFlags.NewInvitation | Sony.NP.PushNotificationsFlags.UpdateBlockedUsersList |
                                           Sony.NP.PushNotificationsFlags.UpdateFriendPresence | Sony.NP.PushNotificationsFlags.UpdateFriendsList);

            Sony.NP.Main.Initialize(init);

            PrintLog("\n NpToolkit has been initialized.");
        }
        catch (Sony.NP.NpToolkitException e)
        {
            Debug.Log("Exception thrown - test past.");
            PrintLog("\n NpToolkit failed to initialized. Error: " + e.Message);
        }
        catch (System.Exception e)
        {
            // Unexcepted expection occured.
            Debug.LogException(e);
            PrintLog("\n NpToolkit failed to initialized. Error: " + e.Message);
        }
#endif
#if ENABLE_WINMD_SUPPORT
        mCurrentUser = Windows.Xbox.ApplicationModel.Core.CoreApplicationContext.CurrentUser;
        mContext     = new XboxLiveContext(mCurrentUser);
#endif
#if UNITY_PS4 || ENABLE_WINMD_SUPPORT
        PrintLog("\n Start Sign-in");
        SignIn();
#endif
    }
    void Init()
    {
        Sony.NP.Main.OnAsyncEvent += Main_OnAsyncEvent;

        Sony.NP.InitToolkit init = new Sony.NP.InitToolkit();

        init.contentRestrictions.DefaultAgeRestriction = 2;

        Sony.NP.AgeRestriction[] ageRestrictions = new Sony.NP.AgeRestriction[1];

        ageRestrictions[0] = new Sony.NP.AgeRestriction(10, new Sony.NP.Core.CountryCode("en"));
        //ageRestrictions[1] = new Sony.NP.AgeRestriction(15, new Sony.NP.Core.CountryCode("au"));

        init.contentRestrictions.AgeRestrictions = ageRestrictions;

        // Only do this if age restriction isn't required for the product. See documentation for details.
        // init.contentRestrictions.ApplyContentRestriction = false;

        init.threadSettings.affinity = Sony.NP.Affinity.AllCores; // Sony.NP.Affinity.Core2 | Sony.NP.Affinity.Core4;

        // Mempools
        init.memoryPools.JsonPoolSize = 6 * 1024 * 1024;
        init.memoryPools.SslPoolSize *= 4;

        init.memoryPools.MatchingSslPoolSize *= 4;
        init.memoryPools.MatchingPoolSize    *= 4;

        init.SetPushNotificationsFlags(Sony.NP.PushNotificationsFlags.None);
        init.contentRestrictions.DefaultAgeRestriction = 0;

        //You can add several age restrictions by region


        //For this example we use the first user

        loggedInUser = PS4Input.RefreshUsersDetails(0);

        try
        {
            initResult = Sony.NP.Main.Initialize(init);

            if (initResult.Initialized == true)
            {
                Debug.LogError("NpToolkit Initialized ");
                Debug.LogError("Plugin SDK Version : " + initResult.SceSDKVersion.ToString());
                Debug.LogError("Plugin DLL Version : " + initResult.DllVersion.ToString());
                //
                RegisterTrophyPack();
            }
            else
            {
                Debug.LogError("NpToolkit not initialized ");
            }
        }
        catch (Sony.NP.NpToolkitException e)
        {
            Debug.LogError("Exception During Initialization : " + e.ExtendedMessage);
        }
#if UNITY_EDITOR
        catch (DllNotFoundException e)
        {
            Debug.LogError("Missing DLL Expection : " + e.Message);
            Debug.LogError("The sample APP will not run in the editor.");
        }
#endif
    }