コード例 #1
0
    void OnGUI()
    {
        beginGuiColomn();

#if UNITY_ANDROID
        if (GUILayout.Button("Enable Verbose Logs (Android only)"))
        {
            Upsight.setLogLevel(UpsightLogLevel.VERBOSE);
        }
#endif


        if (GUILayout.Button("Request App Open"))
        {
            Upsight.requestAppOpen();
        }


        // if we have a more games badge count available use it for the button text
        var moreGamesButtonTitle = "Send Content Request (more_games_only)";
        if (_moreGamesBadgeCount >= 0)
        {
            moreGamesButtonTitle += string.Format(" ({0})", _moreGamesBadgeCount);
        }

        if (GUILayout.Button(moreGamesButtonTitle))
        {
            Upsight.sendContentRequest("more_games_only", true, true);
        }


        if (GUILayout.Button("Send Content Request (interstitial)"))
        {
            Upsight.sendContentRequest("interstitial", true, true);
        }


        if (GUILayout.Button("Send Content Request (optin)"))
        {
            Upsight.sendContentRequest("optin", true, true);
        }


        if (GUILayout.Button("Send Content Request (rewarded)"))
        {
            Upsight.sendContentRequest("rewarded", false, false);
        }


        if (GUILayout.Button("Send Content Request (vg_test)"))
        {
            Upsight.sendContentRequest("vg_test", true);
        }


        if (GUILayout.Button("Send Content Request (vg_test) with dimensions"))
        {
            var dict = new Dictionary <string, object>();
            dict.Add("ua_source", "PlayHaven");
            dict.Add("gold_balance", 2170);
            dict.Add("registered", true);

            Upsight.sendContentRequest("vg_test", true, false, dict);
        }


        if (GUILayout.Button("Toggle Opt Out Status"))
        {
            Upsight.setOptOutStatus(!Upsight.getOptOutStatus());
        }


        endGuiColumn(true);


        if (GUILayout.Button("Preload Content Request (announce)"))
        {
            Upsight.preloadContentRequest("announce");
        }


        if (GUILayout.Button("Send Preloaded Content Request (announce)"))
        {
            Upsight.sendContentRequest("announce", false);
        }


        if (GUILayout.Button("Get Content Badge Number (more_games_only)"))
        {
            Upsight.getContentBadgeNumber("more_games_only");
        }


        if (GUILayout.Button("Track In App Purchase"))
        {
            // we have to go platform depending here due to IAP differences between iOS and Android
#if UNITY_IPHONE
            Upsight.trackInAppPurchase("com.playhaven.unityexample.plasmagun", 1, UpsightIosPurchaseResolution.Buy);
#else
            Upsight.trackInAppPurchase("com.playhaven.unityexample.plasmagun", 1, UpsightAndroidPurchaseResolution.Bought, 45.55, "the-order-id", "Play");
#endif
        }


        if (GUILayout.Button("Report Custom Event"))
        {
            var dict = new Dictionary <string, object>();
            dict.Add("first_key", "first_value");
            dict.Add("second_key", 38);

            Upsight.reportCustomEvent(dict);
        }


        GUILayout.Label("Push Notifications");

        if (GUILayout.Button("Register for Push Notifications"))
        {
            Upsight.registerForPushNotifications();
        }


        if (GUILayout.Button("Deregister for Push Notifications"))
        {
            Upsight.deregisterForPushNotifications();
        }


        // iOS only push features
#if UNITY_IPHONE
        if (GUILayout.Button("Turn off Automatic Opening of Content/Urls"))
        {
            Upsight.setShouldOpenContentRequestsFromPushNotifications(false);
            Upsight.setShouldOpenUrlsFromPushNotifications(false);
        }
#endif

        endGuiColumn();
    }