Esempio n. 1
0
    private void OnGUI()
    {
        GUIStyle style = new GUIStyle();

        style.fontStyle        = FontStyle.Bold;
        style.fontSize         = 50;
        style.alignment        = TextAnchor.MiddleCenter;
        style.normal.textColor = Color.white;
        GUI.Label(new Rect(10f, 5f, (float)(Screen.width - 20), (float)(Screen.height / 10)), "MAT Unity Test App", style);
        GUI.skin.button.fontSize = 40;
        if (GUI.Button(new Rect(10f, (float)(Screen.height / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Start MAT SDK"))
        {
            MonoBehaviour.print("Start MAT SDK clicked");
            MATBinding.Init(this.MAT_ADVERTISER_ID, this.MAT_CONVERSION_KEY);
            MATBinding.SetPackageName(this.MAT_PACKAGE_NAME);
            MATBinding.SetFacebookEventLogging(true, false);
            MATBinding.CheckForDeferredDeeplink();
            MATBinding.AutomateIapEventMeasurement(true);
        }
        else if (GUI.Button(new Rect(10f, (float)((2 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Set Delegate"))
        {
            MonoBehaviour.print("Set Delegate clicked");
            MATBinding.SetDelegate(true);
        }
        else if (GUI.Button(new Rect(10f, (float)((3 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Enable Debug Mode"))
        {
            MonoBehaviour.print("Enable Debug Mode clicked");
            MATBinding.SetDebugMode(true);
        }
        else if (GUI.Button(new Rect(10f, (float)((4 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Allow Duplicates"))
        {
            MonoBehaviour.print("Allow Duplicates clicked");
            MATBinding.SetAllowDuplicates(true);
        }
        else if (GUI.Button(new Rect(10f, (float)((5 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Measure Session"))
        {
            MonoBehaviour.print("Measure Session clicked");
            MATBinding.MeasureSession();
        }
        else if (GUI.Button(new Rect(10f, (float)((6 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Measure Event"))
        {
            MonoBehaviour.print("Measure Event clicked");
            MATBinding.MeasureEvent("evt11");
        }
        else if (GUI.Button(new Rect(10f, (float)((7 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Measure Event With Event Items"))
        {
            MonoBehaviour.print("Measure Event With Event Items clicked");
            MATItem item = new MATItem();
            item.name       = "subitem1";
            item.unitPrice  = 5.0;
            item.quantity   = 5;
            item.revenue    = 3.0;
            item.attribute2 = "attrValue2";
            item.attribute3 = "attrValue3";
            item.attribute4 = "attrValue4";
            item.attribute5 = "attrValue5";
            MATItem item2 = new MATItem();
            item2.name       = "subitem2";
            item2.unitPrice  = 1.0;
            item2.quantity   = 3;
            item2.revenue    = 1.5;
            item2.attribute1 = "attrValue1";
            item2.attribute3 = "attrValue3";
            MATItem[] itemArray = new MATItem[] { item, item2 };
            MATEvent  tuneEvent = new MATEvent("purchase");
            tuneEvent.revenue         = 10.0;
            tuneEvent.currencyCode    = "AUD";
            tuneEvent.advertiserRefId = "ref222";
            tuneEvent.attribute1      = "test_attribute1";
            tuneEvent.attribute2      = "test_attribute2";
            tuneEvent.attribute3      = "test_attribute3";
            tuneEvent.attribute4      = "test_attribute4";
            tuneEvent.attribute5      = "test_attribute5";
            tuneEvent.contentType     = "test_contentType";
            tuneEvent.contentId       = "test_contentId";
            tuneEvent.date1           = new DateTime?(DateTime.UtcNow);
            DateTime time2 = new DateTime(2, 1, 1);
            tuneEvent.date2            = new DateTime?(DateTime.UtcNow.Add(new TimeSpan(time2.Ticks)));
            tuneEvent.level            = 3;
            tuneEvent.quantity         = 2;
            tuneEvent.rating           = 4.5;
            tuneEvent.searchString     = "test_searchString";
            tuneEvent.eventItems       = itemArray;
            tuneEvent.transactionState = 1;
            MATBinding.MeasureEvent(tuneEvent);
        }
        else if (GUI.Button(new Rect(10f, (float)((8 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Test Setter Methods"))
        {
            MonoBehaviour.print("Test Setter Methods clicked");
            MATBinding.SetAge(0x22);
            MATBinding.SetAllowDuplicates(true);
            MATBinding.SetAppAdTracking(true);
            MATBinding.SetDebugMode(true);
            MATBinding.SetExistingUser(false);
            MATBinding.SetFacebookUserId("temp_facebook_user_id");
            MATBinding.SetGender(0);
            MATBinding.SetGoogleUserId("temp_google_user_id");
            MATBinding.SetLocation(111.0, 222.0, 333.0);
            MATBinding.SetPayingUser(true);
            MATBinding.SetPhoneNumber("111-222-3333");
            MATBinding.SetTwitterUserId("twitter_user_id");
            MATBinding.SetUserId("temp_user_id");
            MATBinding.SetUserName("temp_user_name");
            MATBinding.SetUserEmail("*****@*****.**");
            MATBinding.SetDeepLink("myapp://myval1/myval2");
            MATBinding.SetAndroidId("111111111111");
            MATBinding.SetDeviceId("123456789123456");
            MATBinding.SetGoogleAdvertisingId("12345678-1234-1234-1234-123456789012", true);
            MATBinding.SetMacAddress("AA:BB:CC:DD:EE:FF");
            MATBinding.SetCurrencyCode("CAD");
            MATBinding.SetTRUSTeId("1234567890");
            MATPreloadData preloadData = new MATPreloadData("1122334455");
            preloadData.advertiserSubAd = "some_adv_sub_ad_id";
            preloadData.publisherSub3   = "some_pub_sub3";
            MATBinding.SetPreloadedApp(preloadData);
        }
        else if (GUI.Button(new Rect(10f, (float)((9 * Screen.height) / 10), (float)(Screen.width - 20), (float)(Screen.height / 10)), "Test Getter Methods"))
        {
            MonoBehaviour.print("Test Getter Methods clicked");
            MonoBehaviour.print("isPayingUser = "******"tuneId     = " + MATBinding.GetTuneId());
            MonoBehaviour.print("openLogId = " + MATBinding.GetOpenLogId());
        }
    }
Esempio n. 2
0
    void OnGUI()
    {
        GUIStyle headingLabelStyle = new GUIStyle();

        headingLabelStyle.fontStyle        = FontStyle.Bold;
        headingLabelStyle.fontSize         = 50;
        headingLabelStyle.alignment        = TextAnchor.MiddleCenter;
        headingLabelStyle.normal.textColor = Color.white;

        GUI.Label(new Rect(10, 5, Screen.width - 20, Screen.height / 10), "MAT Unity Test App", headingLabelStyle);

        GUI.skin.button.fontSize = 40;

        if (GUI.Button(new Rect(10, Screen.height / 10, Screen.width - 20, Screen.height / 10), "Start MAT SDK"))
        {
            print("Start MAT SDK clicked");
            #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_METRO)
            MATBinding.Init(MAT_ADVERTISER_ID, MAT_CONVERSION_KEY);
            MATBinding.SetPackageName(MAT_PACKAGE_NAME);
            MATBinding.SetFacebookEventLogging(true, false);
            #endif
            #if (UNITY_ANDROID || UNITY_IPHONE)
            MATBinding.CheckForDeferredDeeplink();
            MATBinding.AutomateIapEventMeasurement(true);
            #endif
        }

        else if (GUI.Button(new Rect(10, 2 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Set Delegate"))
        {
            print("Set Delegate clicked");
            #if (UNITY_ANDROID || UNITY_IPHONE)
            MATBinding.SetDelegate(true);
            #endif
            #if UNITY_METRO
            MATBinding.SetMATResponse(new SampleWinMATResponse());
            #endif
        }

        else if (GUI.Button(new Rect(10, 3 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Enable Debug Mode"))
        {
            print("Enable Debug Mode clicked");
            // NOTE: !!! ONLY FOR DEBUG !!!
            // !!! Make sure you set to false
            //     OR
            //     remove the setDebugMode and setAllowDuplicates calls for Production builds !!!
            MATBinding.SetDebugMode(true);
        }

        else if (GUI.Button(new Rect(10, 4 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Allow Duplicates"))
        {
            print("Allow Duplicates clicked");
            // NOTE: !!! ONLY FOR DEBUG !!!
            // !!! Make sure you set to false
            //     OR
            //     remove the setDebugMode and setAllowDuplicates calls for Production builds !!!
            MATBinding.SetAllowDuplicates(true);
        }

        else if (GUI.Button(new Rect(10, 5 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Measure Session"))
        {
            print("Measure Session clicked");
            MATBinding.MeasureSession();
        }

        else if (GUI.Button(new Rect(10, 6 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Measure Event"))
        {
            print("Measure Event clicked");
            MATBinding.MeasureEvent("evt11");
        }

        else if (GUI.Button(new Rect(10, 7 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Measure Event With Event Items"))
        {
            print("Measure Event With Event Items clicked");

            MATItem item1 = new MATItem();
            item1.name       = "subitem1";
            item1.unitPrice  = 5;
            item1.quantity   = 5;
            item1.revenue    = 3;
            item1.attribute2 = "attrValue2";
            item1.attribute3 = "attrValue3";
            item1.attribute4 = "attrValue4";
            item1.attribute5 = "attrValue5";

            MATItem item2 = new MATItem();
            item2.name       = "subitem2";
            item2.unitPrice  = 1;
            item2.quantity   = 3;
            item2.revenue    = 1.5;
            item2.attribute1 = "attrValue1";
            item2.attribute3 = "attrValue3";
            MATItem[] eventItems = { item1, item2 };

            MATEvent tuneEvent = new MATEvent("purchase");
            tuneEvent.revenue         = 10;
            tuneEvent.currencyCode    = "AUD";
            tuneEvent.advertiserRefId = "ref222";
            tuneEvent.attribute1      = "test_attribute1";
            tuneEvent.attribute2      = "test_attribute2";
            tuneEvent.attribute3      = "test_attribute3";
            tuneEvent.attribute4      = "test_attribute4";
            tuneEvent.attribute5      = "test_attribute5";
            tuneEvent.contentType     = "test_contentType";
            tuneEvent.contentId       = "test_contentId";
            tuneEvent.date1           = DateTime.UtcNow;
            tuneEvent.date2           = DateTime.UtcNow.Add(new TimeSpan((new DateTime(2, 1, 1).Ticks)));
            tuneEvent.level           = 3;
            tuneEvent.quantity        = 2;
            tuneEvent.rating          = 4.5;
            tuneEvent.searchString    = "test_searchString";
            tuneEvent.eventItems      = eventItems;
            // transaction state may be set to the value received from the iOS/Android app store.
            tuneEvent.transactionState = 1;

            #if UNITY_IPHONE
            tuneEvent.receipt = getSampleiTunesIAPReceipt();
            #endif

            MATBinding.MeasureEvent(tuneEvent);
        }

        else if (GUI.Button(new Rect(10, 8 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Test Setter Methods"))
        {
            print("Test Setter Methods clicked");
            MATBinding.SetAge(34);
            MATBinding.SetAllowDuplicates(true);
            MATBinding.SetAppAdTracking(true);
            MATBinding.SetDebugMode(true);
            MATBinding.SetExistingUser(false);
            MATBinding.SetFacebookUserId("temp_facebook_user_id");
            MATBinding.SetGender(0);
            MATBinding.SetGoogleUserId("temp_google_user_id");
            MATBinding.SetLocation(111, 222, 333);
            //MATBinding.SetPackageName(MAT_PACKAGE_NAME);
            MATBinding.SetPayingUser(true);
            MATBinding.SetPhoneNumber("111-222-3333");
            MATBinding.SetTwitterUserId("twitter_user_id");
            MATBinding.SetUserId("temp_user_id");
            MATBinding.SetUserName("temp_user_name");
            MATBinding.SetUserEmail("*****@*****.**");
            MATBinding.SetDeepLink("myapp://myval1/myval2");

            //iOS-specific Features
            #if UNITY_IPHONE
            #if UNITY_5
            MATBinding.SetAppleAdvertisingIdentifier(UnityEngine.iOS.Device.advertisingIdentifier, UnityEngine.iOS.Device.advertisingTrackingEnabled);
            MATBinding.SetAppleVendorIdentifier(UnityEngine.iOS.Device.vendorIdentifier);
            #else
            MATBinding.SetAppleAdvertisingIdentifier(UnityEngine.iPhone.advertisingIdentifier, UnityEngine.iPhone.advertisingTrackingEnabled);
            MATBinding.SetAppleVendorIdentifier(UnityEngine.iPhone.vendorIdentifier);
            #endif

            MATBinding.SetDelegate(true);
            MATBinding.SetJailbroken(false);
            MATBinding.SetShouldAutoCollectAppleAdvertisingIdentifier(true);
            MATBinding.SetShouldAutoCollectDeviceLocation(true);
            MATBinding.SetShouldAutoDetectJailbroken(true);
            MATBinding.SetShouldAutoGenerateVendorIdentifier(true);
            MATBinding.SetUseCookieTracking(false);
            #endif

            //Android-specific Features
            #if UNITY_ANDROID
            MATBinding.SetAndroidId("111111111111");
            MATBinding.SetDeviceId("123456789123456");
            MATBinding.SetGoogleAdvertisingId("12345678-1234-1234-1234-123456789012", true);
            MATBinding.SetMacAddress("AA:BB:CC:DD:EE:FF");
            #endif
            //Android and iOS-specific Features
            #if (UNITY_ANDROID || UNITY_IPHONE)
            MATBinding.SetCurrencyCode("CAD");
            MATBinding.SetTRUSTeId("1234567890");

            MATPreloadData pd = new MATPreloadData("1122334455");
            pd.advertiserSubAd = "some_adv_sub_ad_id";
            pd.publisherSub3   = "some_pub_sub3";
            MATBinding.SetPreloadedApp(pd);
            #endif
        }

        else if (GUI.Button(new Rect(10, 9 * Screen.height / 10, Screen.width - 20, Screen.height / 10), "Test Getter Methods"))
        {
            print("Test Getter Methods clicked");
            print("isPayingUser = "******"tuneId     = " + MATBinding.GetTuneId());
            print("openLogId = " + MATBinding.GetOpenLogId());
        }
    }