예제 #1
0
    void OnGUI()
    {
        GUIStyle headingLabelStyle = new GUIStyle();

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

        float titleHeight = Screen.height / 10;

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

        GUI.skin.button.fontSize = 40;

        GUI.skin.verticalScrollbar.fixedWidth      = Screen.width * 0.05f;
        GUI.skin.verticalScrollbarThumb.fixedWidth = Screen.width * 0.05f;

        float scrollViewContentHeight = (float)(numButtons * 0.125) * Screen.height;

        scrollPosition = GUI.BeginScrollView(
            new Rect(0.1f * Screen.width, 0.15f * Screen.height, Screen.width - 0.1f * Screen.width, Screen.height - 0.15f * Screen.height - topMargin - bottomMargin),
            scrollPosition,
            new Rect(0.1f * Screen.width, 0.15f * Screen.height, Screen.width - 0.1f * Screen.width, scrollViewContentHeight));

        int   buttonIndex = 0;
        float yPos        = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        Rect  rect        = new Rect(0.1f * Screen.width, yPos,
                                     0.8f * Screen.width, 0.1f * Screen.height);

        if (GUI.Button(rect, "Start MAT SDK"))
        {
            print("Start MAT SDK clicked");
            MATBinding.Init(MAT_ADVERTISER_ID, MAT_CONVERSION_KEY);
            MATBinding.SetPackageName(MAT_PACKAGE_NAME);
        }

        ++buttonIndex;
        yPos = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        rect = new Rect(0.1f * Screen.width, yPos,
                        0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(rect, "Set Delegate"))
        {
            print("Set Delegate clicked");
            #if (UNITY_ANDROID || UNITY_IPHONE)
            MATBinding.SetDelegate(true);
            #endif
            #if UNITY_METRO
            MATBinding.SetMATResponse(new SampleWinMATResponse());
            #endif
        }

        ++buttonIndex;
        yPos = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        rect = new Rect(0.1f * Screen.width, yPos,
                        0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(rect, "Show Banner"))
        {
            print("Show Banner");
            MATBinding.ShowBanner("place1");
        }

        ++buttonIndex;
        yPos = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        rect = new Rect(0.1f * Screen.width, yPos,
                        0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(rect, "Hide Banner"))
        {
            print("Hide Banner");
            MATBinding.HideBanner();
        }

        ++buttonIndex;
        yPos = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        rect = new Rect(0.1f * Screen.width, yPos,
                        0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(rect, "Destroy Banner"))
        {
            print("Destroy Banner");
            MATBinding.DestroyBanner();
        }

        ++buttonIndex;
        yPos = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        rect = new Rect(0.1f * Screen.width, yPos,
                        0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(rect, "Cache Interstitial"))
        {
            MATAdMetadata metadata = new MATAdMetadata();
            metadata.setBirthDate(DateTime.Today.AddYears(-45));
            metadata.setGender(MATAdGender.FEMALE);
            metadata.setLocation(120.8f, 234.5f, 579.6f);
            metadata.setDebugMode(true);

            HashSet <string> keywords = new HashSet <string>();
            keywords.Add("pro");
            keywords.Add("evening");
            metadata.setKeywords(keywords);

            Dictionary <string, string> customTargets = new Dictionary <string, string>();
            customTargets.Add("type", "game");
            customTargets.Add("subtype1", "adventure");
            customTargets.Add("subtype2", "action");
            metadata.setCustomTargets(customTargets);

            MATBinding.CacheInterstitial("place1", metadata);
        }

        ++buttonIndex;
        yPos = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        rect = new Rect(0.1f * Screen.width, yPos,
                        0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(rect, "Show Interstitial"))
        {
            print("Show Interstitial");
            MATBinding.ShowInterstitial("place1");
        }

        ++buttonIndex;
        yPos = (float)(0.15f + buttonIndex * 0.125) * Screen.height;
        rect = new Rect(0.1f * Screen.width, yPos,
                        0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(rect, "Destroy Interstitial"))
        {
            print("Destroy Interstitial");
            MATBinding.DestroyInterstitial();
        }

        GUI.EndScrollView();

        numButtons = buttonIndex + 1;

        // resize banner ad for current orientation
        MATBinding.LayoutBanner();
    }
예제 #2
0
    private void OnGUI()
    {
        GUIStyle style = new GUIStyle();

        style.fontStyle        = FontStyle.Bold;
        style.fontSize         = 50;
        style.alignment        = TextAnchor.MiddleCenter;
        style.normal.textColor = Color.white;
        float height = Screen.height / 10;

        GUI.Label(new Rect(10f, (float)this.topMargin, (float)(Screen.width - 20), height), "MAT Unity Test App", style);
        GUI.skin.button.fontSize = 40;
        GUI.skin.verticalScrollbar.fixedWidth      = Screen.width * 0.05f;
        GUI.skin.verticalScrollbarThumb.fixedWidth = Screen.width * 0.05f;
        float num2 = ((float)(this.numButtons * 0.125)) * Screen.height;

        this.scrollPosition = GUI.BeginScrollView(new Rect(0.1f * Screen.width, 0.15f * Screen.height, Screen.width - (0.1f * Screen.width), ((Screen.height - (0.15f * Screen.height)) - this.topMargin) - this.bottomMargin), this.scrollPosition, new Rect(0.1f * Screen.width, 0.15f * Screen.height, Screen.width - (0.1f * Screen.width), num2));
        int   num3     = 0;
        float top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        Rect  position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);

        if (GUI.Button(position, "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);
        }
        num3++;
        top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(position, "Set Delegate"))
        {
            MonoBehaviour.print("Set Delegate clicked");
            MATBinding.SetDelegate(true);
        }
        num3++;
        top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(position, "Show Banner"))
        {
            MonoBehaviour.print("Show Banner");
            MATBinding.ShowBanner("place1");
        }
        num3++;
        top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(position, "Hide Banner"))
        {
            MonoBehaviour.print("Hide Banner");
            MATBinding.HideBanner();
        }
        num3++;
        top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(position, "Destroy Banner"))
        {
            MonoBehaviour.print("Destroy Banner");
            MATBinding.DestroyBanner();
        }
        num3++;
        top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(position, "Cache Interstitial"))
        {
            MATAdMetadata metadata = new MATAdMetadata();
            metadata.setBirthDate(new DateTime?(DateTime.Today.AddYears(-45)));
            metadata.setGender(MATAdGender.FEMALE);
            metadata.setLocation(120.8f, 234.5f, 579.6f);
            metadata.setDebugMode(true);
            HashSet <string> keywords = new HashSet <string>();
            keywords.Add("pro");
            keywords.Add("evening");
            metadata.setKeywords(keywords);
            Dictionary <string, string> customTargets = new Dictionary <string, string>();
            customTargets.Add("type", "game");
            customTargets.Add("subtype1", "adventure");
            customTargets.Add("subtype2", "action");
            metadata.setCustomTargets(customTargets);
            MATBinding.CacheInterstitial("place1", metadata);
        }
        num3++;
        top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(position, "Show Interstitial"))
        {
            MonoBehaviour.print("Show Interstitial");
            MATBinding.ShowInterstitial("place1");
        }
        num3++;
        top      = ((float)(0.15000000596046448 + (num3 * 0.125))) * Screen.height;
        position = new Rect(0.1f * Screen.width, top, 0.8f * Screen.width, 0.1f * Screen.height);
        if (GUI.Button(position, "Destroy Interstitial"))
        {
            MonoBehaviour.print("Destroy Interstitial");
            MATBinding.DestroyInterstitial();
        }
        GUI.EndScrollView();
        this.numButtons = num3 + 1;
        MATBinding.LayoutBanner();
    }