Example #1
0
        /// <summary> Creates a new ThemeData asset with the given theme name and adds a reference to it to the database </summary>
        /// <param name="themeName"> The name of the new theme </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 CreateTheme(string themeName, bool showDialog = false, bool saveAssets = false)
        {
            themeName = themeName.Trim();

            if (string.IsNullOrEmpty(themeName))
            {
#if UNITY_EDITOR
                if (showDialog)
                {
                    EditorUtility.DisplayDialog(UILabels.NewTheme, UILabels.EnterThemeName, UILabels.Ok);
                }
#endif
                return(false);
            }

            if (Contains(themeName))
            {
#if UNITY_EDITOR
                if (showDialog)
                {
                    EditorUtility.DisplayDialog(UILabels.NewTheme, UILabels.ThemeNameAlreadyExists, UILabels.Ok);
                }
#endif
                return(false);
            }

#if UNITY_EDITOR
            ThemeData themeData = AssetUtils.CreateAsset <ThemeData>(DoozyPath.GetDataPath(DoozyPath.ComponentName.Themes), GetThemeDataFilename(themeName.Replace(" ", string.Empty)));
#else
            ThemeData themeData = ScriptableObject.CreateInstance <ThemeData>();
#endif
            if (themeData == null)
            {
                return(false);
            }
            themeData.ThemeName = themeName;
            themeData.name      = themeName;
            themeData.Init(false, false);
            themeData.SetDirty(false);
            AddTheme(themeData, false);
            SetDirty(saveAssets);
            return(true);
        }
Example #2
0
        /// <summary> Creates a new ListOfNames asset with the given category name and adds a reference to it to the database. Returns TRUE if the operation was successful </summary>
        /// <param name="categoryName"> The category name of the new ListOfNames </param>
        /// <param name="names"> Names to be added to the list </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 CreateCategory(string categoryName, List <string> names, bool showDialog = false, bool saveAssets = false)
        {
            categoryName = categoryName.Trim();
            if (string.IsNullOrEmpty(categoryName))
            {
#if UNITY_EDITOR
                if (showDialog)
                {
                    EditorUtility.DisplayDialog(UILabels.NewCategory, UILabels.EnterCategoryName, UILabels.Ok);
                }
#endif
                return(false);
            }

            if (Contains(categoryName))
            {
#if UNITY_EDITOR
                if (showDialog)
                {
                    EditorUtility.DisplayDialog(UILabels.NewCategory, UILabels.AnotherEntryExists, UILabels.Ok);
                }
#endif
                return(false);
            }

#if UNITY_EDITOR
            var listOfNames = AssetUtils.CreateAsset <ListOfNames>(GetPath(DatabaseType), GetDatabaseFileName(DatabaseType, categoryName));
#else
            ListOfNames listOfNames = ScriptableObject.CreateInstance <ListOfNames>();
#endif

            listOfNames.CategoryName = categoryName;
            listOfNames.AddNames(names, true, false);
            listOfNames.DatabaseType = DatabaseType;
            listOfNames.SetDirty(false);
            Categories.Add(listOfNames);
            UpdateListOfCategoryNames();
            SetDirty(saveAssets);
            return(true);
        }
Example #3
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);
        }
Example #4
0
        /// <summary> Creates a new SoundDatabase asset with the given database name and adds a reference to it to the database </summary>
        /// <param name="databaseName"> The name of the new SoundDatabase </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 CreateSoundDatabase(string databaseName, bool showDialog = false, bool saveAssets = false)
        {
            databaseName = databaseName.Trim();

            if (string.IsNullOrEmpty(databaseName))
            {
#if UNITY_EDITOR
                if (showDialog)
                {
                    EditorUtility.DisplayDialog(UILabels.NewSoundDatabase, UILabels.EnterDatabaseName, UILabels.Ok);
                }
#endif
                return(false);
            }

            if (Contains(databaseName))
            {
#if UNITY_EDITOR
                if (showDialog)
                {
                    EditorUtility.DisplayDialog(UILabels.NewSoundDatabase, UILabels.DatabaseAlreadyExists, UILabels.Ok);
                }
#endif
                return(false);
            }

#if UNITY_EDITOR
            SoundDatabase soundDatabase = AssetUtils.CreateAsset <SoundDatabase>(DoozyPath.GetDataPath(DoozyPath.ComponentName.Soundy), SoundyManager.GetSoundDatabaseFilename(databaseName.Replace(" ", string.Empty)));
#else
            SoundDatabase soundDatabase = ScriptableObject.CreateInstance <SoundDatabase>();
#endif
            soundDatabase.DatabaseName = databaseName;
            soundDatabase.Initialize(false);
            AddSoundDatabase(soundDatabase, false);
            SetDirty(saveAssets);
            return(true);
        }
Example #5
0
        /// <summary> Adds the default categories to the database by taking into account the database type. Returns TRUE if the operation was successful </summary>
        /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param>
        public void AddDefaultCategories(bool saveAssets)
        {
            if (!Contains(GENERAL))
            {
//                CreateCategory(GENERAL, new List<string>(), false, false);
#if UNITY_EDITOR
                var listOfNames = AssetUtils.CreateAsset <ListOfNames>(GetPath(DatabaseType), GetDatabaseFileName(DatabaseType, GENERAL));
#else
                ListOfNames listOfNames = ScriptableObject.CreateInstance <ListOfNames>();
#endif
                listOfNames.CategoryName = GENERAL;
                listOfNames.DatabaseType = DatabaseType;
                Categories.Add(listOfNames);
                UpdateListOfCategoryNames();
                SetDirty(saveAssets);
            }

            ListOfNames general = GetCategory(GENERAL);

            switch (DatabaseType)
            {
            case NamesDatabaseType.UIButton:
                if (!general.Contains(UNNAMED))
                {
                    general.AddName(UNNAMED, false);
                }
                if (!general.Contains(BACK))
                {
                    general.AddName(BACK, false);
                }
                break;

            case NamesDatabaseType.UICanvas:
                if (!general.Contains(MASTER_CANVAS))
                {
                    general.AddName(MASTER_CANVAS, false);
                }
                break;

            case NamesDatabaseType.UIView:
                if (!general.Contains(UNNAMED))
                {
                    general.AddName(UNNAMED, false);
                }
                break;

            case NamesDatabaseType.UIDrawer:
                if (!general.Contains(UNNAMED))
                {
                    general.AddName(UNNAMED, false);
                }
                if (!general.Contains(LEFT))
                {
                    general.AddName(LEFT, false);
                }
                if (!general.Contains(RIGHT))
                {
                    general.AddName(RIGHT, false);
                }
                if (!general.Contains(UP))
                {
                    general.AddName(UP, false);
                }
                if (!general.Contains(DOWN))
                {
                    general.AddName(DOWN, false);
                }
                break;
            }
        }
Example #6
0
 public static void CreateLevelModel()
 {
     AssetUtils.CreateAsset <LevelModel>("Assets/Resources/Levels", string.Format(LEVEL_PREFIX_FORMAT, _levelCount++));
 }