Example #1
0
        void Start()
        {
            DontDestroyOnLoad(gameObject);

            #if !UNITY_EDITOR
            Main.OnAsyncEvent += MainOnAsyncEvent;

            InitToolkit init = new InitToolkit();
            init.contentRestrictions.DefaultAgeRestriction   = ContentRestriction.NP_NO_AGE_RESTRICTION;
            init.contentRestrictions.ApplyContentRestriction = false;
            init.SetPushNotificationsFlags(PushNotificationsFlags.None);
            init.threadSettings.affinity  = Affinity.AllCores;
            init.memoryPools.JsonPoolSize = 6 * 1024 * 1024;
            init.memoryPools.SslPoolSize *= 4;

            initResult = Main.Initialize(init);
            if (!initResult.Initialized)
            {
                return;
            }

            loggedInUser = PS4Input.RefreshUsersDetails(Utility.primaryUserId);
            PS4PlayerPrefs.SetTitleStrings("Gunhouse", "Load your guns! Rain death from above!", "Save Data");
            StartTrophy();
            #endif
        }
Example #2
0
        // Toggle the gamepad between connected and disconnected states
        void ToggleGamePad(bool active)
        {
            if (active)
            {
#if UNITY_PS4
                // Set 3D Text to whoever's using the pad
                loggedInUser = PS4Input.RefreshUsersDetails(playerId);
#endif
                hasSetupGamepad = true;
            }
            else
            {
                // Hide the touches
                touches[0].gameObject.SetActive(false);
                touches[1].gameObject.SetActive(false);

                hasSetupGamepad = false;
            }
        }
Example #3
0
    // Toggle the gamepad between connected and disconnected states
    void ToggleGamePad(bool active)
    {
        if (active)
        {
            // Set the lightbar colour to the start/default value
            lightbarColour = GetPlayerColor(PS4Input.GetUsersDetails(playerId).color);

            // Set 3D Text to whoever's using the pad
            loggedInUser      = PS4Input.RefreshUsersDetails(playerId);
            gamePad.text.text = loggedInUser.userName + "\n(" + connectionType + ")";

            // Reset and show the gyro
            gamePad.gyro.localRotation = Quaternion.identity;
            gamePad.gyro.gameObject.SetActive(true);

            hasSetupGamepad = true;
        }
        else
        {
            // Hide the touches
            touches[0].gameObject.SetActive(false);
            touches[1].gameObject.SetActive(false);

            // Set the lightbar to a default colour
            lightbarColour         = Color.gray;
            gamePad.lightbar.color = lightbarColour;
            gamePad.light.color    = Color.black;

            // Set the 3D Text to show the pad is disconnected
            gamePad.text.text = "Disconnected";

            // Hide the gyro
            gamePad.gyro.gameObject.SetActive(false);

            hasSetupGamepad = false;
        }
    }
    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
    }