Example #1
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);
        }