Esempio n. 1
0
    void OnGUI()
    {
        int buttonHeight = Screen.height / 13;
        int buttonWidth  = Screen.width / 2;
        int buttonSpace  = buttonHeight / 2;
        int startHeight  = buttonHeight / 2;

        if (GUI.Button(new Rect(Screen.width / 4, startHeight, buttonWidth, buttonHeight), "show banner ad"))
        {
            if (!Yodo1U3dAds.BannerIsReady())
            {
                Debug.Log("[Yodo1 Ads] Banner ad has not been cached.");
                return;
            }

            if (isTimes)
            {
                isTimes = false;
                Yodo1U3dAds.SetBannerAlign(Yodo1U3dAdsConstants.BannerAdAlign.BannerAdAlignTop |
                                           Yodo1U3dAdsConstants.BannerAdAlign.BannerAdAlignHorizontalCenter);
                if (IsiPhoneX())
                {
                    Yodo1U3dAds.SetBannerOffset(0.0f, 44.0f);
                }
            }

            //Show banner ad
            Yodo1U3dAds.ShowBanner();
        }

        if (GUI.Button(new Rect(Screen.width / 4, startHeight + buttonSpace + buttonHeight, buttonWidth, buttonHeight),
                       "hide banner ad"))
        {
            //Hide banner ad
            Yodo1U3dAds.HideBanner();
        }

        if (GUI.Button(
                new Rect(Screen.width / 4, startHeight + buttonHeight * 2 + buttonSpace * 2, buttonWidth, buttonHeight),
                "show interstitial ad"))
        {
            //Show interstitial ad
            if (Yodo1U3dAds.InterstitialIsReady())
            {
                Yodo1U3dAds.ShowInterstitial();
            }
            else
            {
                Debug.Log("[Yodo1 Ads] Interstitial ad has not been cached.");
            }
        }

        if (GUI.Button(
                new Rect(Screen.width / 4, startHeight + buttonHeight * 3 + buttonSpace * 3, buttonWidth, buttonHeight),
                "show reward video ad"))
        {
            //Show reward video ad
            if (Yodo1U3dAds.VideoIsReady())
            {
                Yodo1U3dAds.ShowVideo();
            }
            else
            {
                Debug.Log("[Yodo1 Ads] Reward video ad has not been cached.");
            }
        }

        if (GUI.Button(
                new Rect(Screen.width / 4, startHeight + buttonHeight * 4 + buttonSpace * 4, buttonWidth, buttonHeight),
                "show lucky wheel"))
        {
            //Show reward game
            if (Yodo1U3dAds.RewardGameIsEnable())
            {
                Yodo1U3dAds.ShowRewardGame();
            }
            else
            {
                Debug.Log("[Yodo1 Ads] Reward game is disabled.");
            }
        }

        if (GUI.Button(
                new Rect(Screen.width / 4, startHeight + buttonHeight * 5 + buttonSpace * 5, buttonWidth, buttonHeight),
                "返回"))
        {
            SceneManager.LoadScene("Yodo1Demo");
        }
    }