public void RemoveAndDestroyAllPrefabCategories(bool showProgresBar = false)
        {
            List <PrefabCategory> allPrefabCategories = GetAllPrefabCategories();
            var prefabCategoriesToDestroy             = new List <PrefabCategory>();

            foreach (PrefabCategory prefabCategory in allPrefabCategories)
            {
                if (CanPrefabCategoryBeRemovedFromDatabase(prefabCategory))
                {
                    _prefabCategories.RemoveEntity(prefabCategory);
                    PrefabCategoryWasRemovedFromDatabaseMessage.SendToInterestedListeners(prefabCategory);

                    prefabCategoriesToDestroy.Add(prefabCategory);
                }
            }

            if (showProgresBar)
            {
                for (int categoryIndex = 0; categoryIndex < prefabCategoriesToDestroy.Count; ++categoryIndex)
                {
                    PrefabCategory prefabCategory = prefabCategoriesToDestroy[categoryIndex];
                    EditorUtility.DisplayProgressBar("Removing categories", "Please wait... (" + prefabCategory.Name + ")", (categoryIndex + 1) / (float)prefabCategoriesToDestroy.Count);
                    UndoEx.DestroyObjectImmediate(prefabCategory);
                }
                EditorUtility.ClearProgressBar();
            }
            else
            {
                foreach (PrefabCategory prefabCategory in prefabCategoriesToDestroy)
                {
                    UndoEx.DestroyObjectImmediate(prefabCategory);
                }
            }
        }
        public void RemoveAndDestroyPrefabCategory(PrefabCategory prefabCategory)
        {
            if (CanPrefabCategoryBeRemovedFromDatabase(prefabCategory))
            {
                if (ContainsPrefabCategory(prefabCategory))
                {
                    _prefabCategories.RemoveEntity(prefabCategory);
                    PrefabCategoryWasRemovedFromDatabaseMessage.SendToInterestedListeners(prefabCategory);

                    UndoEx.DestroyObjectImmediate(prefabCategory);
                }
            }
        }
        public void RemoveAndDestroyEmptyPrefabCategories()
        {
            List <PrefabCategory> allPrefabCategories = GetAllPrefabCategories();
            var prefabCategoriesToDestroy             = new List <PrefabCategory>();

            foreach (PrefabCategory prefabCategory in allPrefabCategories)
            {
                if (prefabCategory.IsEmpty && CanPrefabCategoryBeRemovedFromDatabase(prefabCategory))
                {
                    _prefabCategories.RemoveEntity(prefabCategory);
                    PrefabCategoryWasRemovedFromDatabaseMessage.SendToInterestedListeners(prefabCategory);

                    prefabCategoriesToDestroy.Add(prefabCategory);
                }
            }

            foreach (PrefabCategory prefabCategory in prefabCategoriesToDestroy)
            {
                UndoEx.DestroyObjectImmediate(prefabCategory);
            }
        }
Exemplo n.º 4
0
        public static void SendToInterestedListeners(PrefabCategory prefabCategoryWhichWasRemoved)
        {
            var message = new PrefabCategoryWasRemovedFromDatabaseMessage(prefabCategoryWhichWasRemoved);

            MessageListenerDatabase.Instance.SendMessageToInterestedListeners(message);
        }
Exemplo n.º 5
0
 private void RespondToMessage(PrefabCategoryWasRemovedFromDatabaseMessage message)
 {
     DestroyIfExists();
     CreateFromActivePrefabIfNotExists();
 }