/// <summary>
 /// An Enabled Ad types is option to increase application performance by initializing only those ad types that will be used.
 /// <para>For example: .withEnabledAdTypes(AdFlags.Banner, AdFlags.Interstitial)</para>
 /// <para>Changes in current session only.</para>
 /// <para>Ad types can be enabled manually after initialize by <see cref="IMediationManager.SetEnableAd(AdType, bool)"/></para>
 /// </summary>
 public CASInitSettings WithEnabledAdTypes(params AdFlags[] adTypes)
 {
     allowedAdFlags = AdFlags.None;
     for (int i = 0; i < adTypes.Length; i++)
     {
         allowedAdFlags |= adTypes[i];
     }
     return(this);
 }
 public static IMediationManager Initialize(
     string managerID,
     AdFlags enableAd = AdFlags.Everything,
     bool testAdMode  = false,
     InitCompleteAction initCompleteAction = null)
 {
     return(BuildManager()
            .WithManagerId(managerID)
            .WithEnabledAdTypes(enableAd)
            .WithTestAdMode(testAdMode)
            .WithInitListener(initCompleteAction)
            .Initialize());
 }
        public static IMediationManager InitializeFromResources(
            int managerIndex = 0,
            AdFlags enableAd = AdFlags.Everything,
            InitCompleteAction initCompleteAction = null)
        {
            var builder = BuildManager()
                          .WithInitListener(initCompleteAction);

            builder.WithEnabledAdTypes(enableAd & builder.allowedAdFlags);
            if (managerIndex > 0)
            {
                builder.WithManagerIdAtIndex(managerIndex);
            }
            return(builder.Initialize());
        }
Beispiel #4
0
 public void SetEnableAd(AdType adType, bool enabled)
 {
     if (enabled)
     {
         enabledTypes |= GetFlag(adType);
         if (adType == AdType.Banner)
         {
             viewFactory.LoadCreatedViews();
         }
         else
         {
             LoadAd(adType);
         }
         return;
     }
     enabledTypes &= ~GetFlag(adType);
 }
        public static Texture GetFormatIcon(AdFlags format, bool active)
        {
            int iconIndex;

            switch (format)
            {
            case AdFlags.Banner: iconIndex = 0; break;

            case AdFlags.Interstitial: iconIndex = 1; break;

            case AdFlags.Rewarded: iconIndex = 2; break;

            case AdFlags.Native: iconIndex = 3; break;

            case AdFlags.MediumRectangle: iconIndex = 4; break;

            default: return(null);
            }
            return(formatIcons[active ? iconIndex : iconIndex + 5]);
        }
Beispiel #6
0
        private bool DrawAdFlagToggle(AdFlags flag)
        {
            var flagInt = ( int )flag;
            var enabled = (allowedAdFlagsProp.intValue & flagInt) == flagInt;
            var icon    = HelpStyles.GetFormatIcon(flag, enabled);
            var content = HelpStyles.GetContent("", icon, "Use " + flag.ToString() + " placement");

            EditorGUI.BeginDisabledGroup(flag == AdFlags.Native);
            if (flag == AdFlags.Native)
            {
                if (enabled)
                {
                    allowedAdFlagsProp.intValue = allowedAdFlagsProp.intValue ^ flagInt;
                    enabled = false;
                }
                content.tooltip = "Native ads coming soon";
            }
            if (icon == null)
            {
                content.text    = content.tooltip;
                content.tooltip = "";
            }
            if (enabled != GUILayout.Toggle(enabled, content, "button", GUILayout.ExpandWidth(false), GUILayout.MinWidth(45)))
            {
                enabled = !enabled;
                if (enabled)
                {
                    allowedAdFlagsProp.intValue = allowedAdFlagsProp.intValue | flagInt;
                }
                else
                {
                    allowedAdFlagsProp.intValue = allowedAdFlagsProp.intValue ^ flagInt;
                }
            }
            EditorGUI.EndDisabledGroup();
            return(enabled);
        }