/// <summary> Initializes this theme by checking if it has the 'Default' variant. If it does not, it adds it </summary>
 /// <param name="showProgress"> Should a progress window be shown while executing the action </param>
 /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param>
 public void Init(bool showProgress, bool saveAssets)
 {
     RefreshThemeVariants(showProgress, false, saveAssets);
     if (ActiveVariant == null || !ContainsVariant(ActiveVariant.Id))
     {
         m_activeVariant = Variants[0];
     }
 }
 /// <summary> Activate the given variant by its name </summary>
 /// <param name="variantName"> Variant name of the variant to activate </param>
 public void ActivateVariant(string variantName)
 {
     if (string.IsNullOrEmpty(variantName))
     {
         return;
     }
     m_activeVariant = GetVariant(variantName);
     SetDirty(false);
 }
 /// <summary> Activate the given variant by Guid </summary>
 /// <param name="variantId"> Variant Id of the variant to activate </param>
 public void ActivateVariant(Guid variantId)
 {
     if (variantId == Guid.Empty || !ContainsVariant(variantId))
     {
         return;
     }
     m_activeVariant = GetVariant(variantId);
     SetDirty(false);
 }
 /// <summary> Activate the given variant </summary>
 /// <param name="variant"> Variant to activate </param>
 public void ActivateVariant(ThemeVariantData variant)
 {
     if (variant == null || !Variants.Contains(variant))
     {
         return;
     }
     m_activeVariant = variant;
     SetDirty(false);
 }
        /// <summary> Add the 'Default' variant to the database (if it does not exist) </summary>
        /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param>
        private bool AddDefaultVariant(bool saveAssets = false)
        {
            if (Variants.Count > 0 || ContainsVariant(DEFAULT_VARIANT_NAME))
            {
                return(false);
            }
            VariantsNames.Add(DEFAULT_VARIANT_NAME);
            var variant = new ThemeVariantData(DEFAULT_VARIANT_NAME,
                                               ColorLabels,
                                               SpriteLabels,
                                               TextureLabels,
                                               FontLabels,
                                               FontAssetLabels);

            Variants.Add(variant);
            SetDirty(saveAssets);
            return(true);
        }
        /// <summary> Iterate through the database to look for the given variant. If found, removes the entry and returns TRUE </summary>
        /// <param name="data"> ThemeVariantData to search for </param>
        /// <param name="performUndo"> Record changes? </param>
        /// <param name="showDialog"> Should a display dialog be shown before executing the action </param>
        /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param>
        public bool RemoveVariant(ThemeVariantData data, bool performUndo = false, bool showDialog = false, bool saveAssets = false)
        {
            if (data == null)
            {
                return(false);
            }
            if (!Variants.Contains(data))
            {
                return(false);
            }
#if UNITY_EDITOR
            if (showDialog)
            {
                if (!EditorUtility.DisplayDialog(UILabels.RemovedEntry + " '" + data.VariantName + "'",
                                                 UILabels.AreYouSureYouWantToRemoveTheEntry,
                                                 UILabels.Yes,
                                                 UILabels.No))
                {
                    return(false);
                }
            }
#endif

            for (int i = Variants.Count - 1; i >= 0; i--)
            {
                if (Variants[i] == data)
                {
                    if (performUndo)
                    {
                        UndoRecord(UILabels.RemovedEntry);
                    }
                    Variants.RemoveAt(i);
                    break;
                }
            }

            UpdateVariantsNames(false);
            SetDirty(saveAssets);

            return(true);
        }