示例#1
0
        /// <summary> Resets the database to the default values </summary>
        public bool ResetDatabase()
        {
#if UNITY_EDITOR
            if (!EditorUtility.DisplayDialog(UILabels.ResetDatabase,
                                             UILabels.AreYouSureYouWantToResetDatabase +
                                             "\n\n" +
                                             UILabels.OperationCannotBeUndone,
                                             UILabels.Yes,
                                             UILabels.No))
            {
                return(false);
            }

            for (int i = Popups.Count - 1; i >= 0; i--)
            {
                UIPopupLink link = Popups[i];
                Popups.Remove(link);
                DoozyUtils.MoveAssetToTrash(AssetDatabase.GetAssetPath(link));
            }

            UpdateListOfPopupNames();
            SetDirty(true);
            DDebug.Log(UILabels.DatabaseHasBeenReset);
#endif
            return(true);
        }
示例#2
0
        /// <summary> Deletes a reference from the database. Returns TRUE if the operation was successful </summary>
        /// <param name="reference"> Target link to be deleted </param>
        public bool DeletePopupLink(UIPopupLink reference)
        {
            if (reference == null || !Popups.Contains(reference))
            {
                return(false);                                                  //sanity check
            }
#if UNITY_EDITOR
            string popupName = reference.PopupName;
            if (!EditorUtility.DisplayDialog(UILabels.DeletePopupReference + " '" + popupName + "'",
                                             UILabels.AreYouSureYouWantToDeletePopupReference +
                                             "\n\n" +
                                             UILabels.OperationCannotBeUndone,
                                             UILabels.Yes,
                                             UILabels.No))
            {
                return(false);
            }

            Popups.Remove(reference);
            DoozyUtils.MoveAssetToTrash(AssetDatabase.GetAssetPath(reference));
            UpdateListOfPopupNames();
            SetDirty(false);
#endif
            return(true);
        }
示例#3
0
 /// <summary> Adds a new entry to the database. Returns TRUE if the operation was successful </summary>
 /// <param name="popupLink"> Popup link asset </param>
 /// <param name="performUndo"> Record changes? </param>
 /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param>
 public bool Add(UIPopupLink popupLink, bool performUndo, bool saveAssets)
 {
     if (popupLink == null)
     {
         return(false);
     }
     if (Popups == null)
     {
         Popups = new List <UIPopupLink>();
     }
     if (performUndo)
     {
         UndoRecord(UILabels.AddItem);
     }
     Popups.Add(popupLink);
     UpdateListOfPopupNames();
     SetDirty(saveAssets);
     return(true);
 }
示例#4
0
        /// <summary> [Editor Only] Performs a deep search through the project for any unregistered UIPopupLink asset files and adds them to the database. The search is done only in all the Resources folders. </summary>
        /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param>
        public void SearchForUnregisteredLinks(bool saveAssets)
        {
            string title = UILabels.Database + ": UIPopup"; // ProgressBar Title
            string info  = UILabels.Search;                 // ProgressBar Info

            DoozyUtils.DisplayProgressBar(title, info, 0.1f);
            bool foundUnregisteredLink = false;

            UIPopupLink[] array = Resources.LoadAll <UIPopupLink>("");
            if (array == null || array.Length == 0)
            {
                DoozyUtils.ClearProgressBar();
                return;
            }

            if (Popups == null)
            {
                Popups = new List <UIPopupLink>();
            }
            for (int i = 0; i < array.Length; i++)
            {
                DoozyUtils.DisplayProgressBar(title, info, 0.1f + 0.8f * (i + 1) / array.Length);
                UIPopupLink link = array[i];
                if (Popups.Contains(link))
                {
                    continue;
                }
                Popups.Add(link);
                foundUnregisteredLink = true;
            }

            DoozyUtils.DisplayProgressBar(title, info, 1f);
            if (!foundUnregisteredLink)
            {
                DoozyUtils.ClearProgressBar();
                return;
            }

            UpdateListOfPopupNames();
            SetDirty(saveAssets);
            DoozyUtils.ClearProgressBar();
        }
示例#5
0
        /// <summary> Creates a new UIPopupLink asset with the given settings and adds a reference to it to the database. Returns TRUE if the operation was successful </summary>
        /// <param name="popupName"> Popup name used to retrieve the prefab </param>
        /// <param name="prefab"> Prefab reference </param>
        /// <param name="performUndo"> Record changes? </param>
        /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param>
        public bool CreateUIPopupLink(string popupName, GameObject prefab, bool performUndo, bool saveAssets)
        {
            popupName = popupName.Trim();
            if (string.IsNullOrEmpty(popupName))
            {
                DDebug.Log(UILabels.NewPopup + ": " + UILabels.CannotAddEmptyEntry + " " + UILabels.PleaseEnterNewName);

#if UNITY_EDITOR
                EditorUtility.DisplayDialog(UILabels.NewPopup,
                                            UILabels.CannotAddEmptyEntry + "\n\n" + UILabels.PleaseEnterNewName,
                                            UILabels.Ok);
#endif
                return(false);
            }

            if (Contains(popupName))
            {
                DDebug.Log(UILabels.NewPopup + ": " + UILabels.AnotherEntryExists + " " + UILabels.PleaseEnterNewName);

#if UNITY_EDITOR
                EditorUtility.DisplayDialog(UILabels.NewPopup,
                                            UILabels.AnotherEntryExists + "\n\n" + UILabels.PleaseEnterNewName,
                                            UILabels.Ok);
#endif

                return(false);
            }

#if UNITY_EDITOR
            UIPopupLink link = AssetUtils.CreateAsset <UIPopupLink>(DoozyPath.ENGINE_RESOURCES_DATA_UIPOPUP_PATH, "UIPopupLink_" + popupName);
#else
            UIPopupLink link = ScriptableObject.CreateInstance <UIPopupLink>();
#endif

            link.PopupName = popupName;
            link.Prefab    = prefab;
            Add(link, false, saveAssets);
            return(true);
        }
示例#6
0
        /// <summary> Removes the link with the passed popup name (if it exists) </summary>
        /// <param name="popupName"> Popup name to search for (null or empty will get ignored and return FALSE)</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 void RemoveLink(string popupName, bool showDialog, bool saveAssets)
        {
            if (!Contains(popupName))
            {
                return;
            }
#if UNITY_EDITOR
            if (showDialog)
            {
                if (!EditorUtility.DisplayDialog(UILabels.DeletePopupReference + " '" + popupName + "'",
                                                 UILabels.AreYouSureYouWantToDeletePopupReference + "\n\n" + UILabels.OperationCannotBeUndone,
                                                 UILabels.Yes,
                                                 UILabels.No))
                {
                    return;
                }
            }
#endif

            bool needSave = false;
            for (int i = Popups.Count - 1; i >= 0; i--)
            {
                UIPopupLink link = Popups[i];
                if (link.PopupName != popupName)
                {
                    continue;
                }
                if (DeletePopupLink(link))
                {
                    needSave = true;
                }
            }

            if (needSave)
            {
                SetDirty(saveAssets);
            }
        }