public static void ActivatePreviousPrefabInPrefabCategory(PrefabCategory prefabCategory) { List <Prefab> filteredPrefabs = prefabCategory.GetFilteredPrefabs(); int prefabIndex = prefabCategory.GetPrefabIndex(prefabCategory.ActivePrefab) - 1; if (prefabIndex < 0) { prefabIndex = prefabCategory.NumberOfPrefabs - 1; } while (prefabIndex >= 0) { Prefab newActivePrefab = prefabCategory.GetPrefabByIndex(prefabIndex); if (filteredPrefabs.Contains(newActivePrefab)) { prefabCategory.SetActivePrefab(newActivePrefab); return; } --prefabIndex; } prefabCategory.SetActivePrefab(null); }
private void AcquireFilteredPrefabs() { if (_prefabCategory == null) { _filteredPrefabs = new List <Prefab>(); } else { _filteredPrefabs = _prefabCategory.GetFilteredPrefabs(); } }
private void RenderActionsView() { EditorGUILayout.BeginHorizontal(); var content = new GUIContent(); content.text = "Move"; content.tooltip = "Allows you to move prefabs to a destination category. The popup controls to the right allow you to choose what prefabs will be moved and to which category."; if (GUILayout.Button(content, GUILayout.Width(100.0f))) { if (ViewData.PrefabMoveType == PrefabMoveType.AllPrefabs) { PrefabCategory destinationCategory = ViewData.DestinationCategoryForPrefabMove; if (destinationCategory != null) { UndoEx.RecordForToolAction(destinationCategory); UndoEx.RecordForToolAction(PrefabCategoryDatabase.Get().ActivePrefabCategory); PrefabCategoryDatabase.Get().ActivePrefabCategory.TransferAllPrefabsToCategory(destinationCategory); } } else if (ViewData.PrefabMoveType == PrefabMoveType.FilteredPrefabs) { PrefabCategory destinationCategory = ViewData.DestinationCategoryForPrefabMove; if (destinationCategory != null) { PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory; UndoEx.RecordForToolAction(destinationCategory); UndoEx.RecordForToolAction(activePrefabCategory); activePrefabCategory.TransferPrefabCollectionToCategory(activePrefabCategory.GetFilteredPrefabs(), destinationCategory); } } else if (ViewData.PrefabMoveType == PrefabMoveType.ActivePrefab) { Prefab activePrefab = PrefabCategoryDatabase.Get().ActivePrefabCategory.ActivePrefab; if (activePrefab != null) { PrefabCategory destinationCategory = ViewData.DestinationCategoryForPrefabMove; if (destinationCategory != null) { PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory; UndoEx.RecordForToolAction(PrefabCategoryDatabase.Get()); UndoEx.RecordForToolAction(destinationCategory); UndoEx.RecordForToolAction(activePrefabCategory); activePrefabCategory.TransferPrefabToCategory(activePrefab, destinationCategory); PrefabCategoryDatabase.Get().SetActivePrefabCategory(destinationCategory); destinationCategory.SetActivePrefab(activePrefab); } } } } PrefabMoveType newPrefabMoveType = (PrefabMoveType)EditorGUILayout.EnumPopup(ViewData.PrefabMoveType); if (newPrefabMoveType != ViewData.PrefabMoveType) { UndoEx.RecordForToolAction(ViewData); ViewData.PrefabMoveType = newPrefabMoveType; } List <string> allPrefabCategoryNames = PrefabCategoryDatabase.Get().GetAllPrefabCategoryNames(); string newString = EditorGUILayoutEx.Popup(new GUIContent(), ViewData.DestinationCategoryForPrefabMove.Name, allPrefabCategoryNames); if (newString != ViewData.DestinationCategoryForPrefabMove.Name) { UndoEx.RecordForToolAction(ViewData); ViewData.DestinationCategoryForPrefabMove = PrefabCategoryDatabase.Get().GetPrefabCategoryByName(newString); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); RenderSetPrefabOffsetFromGridSurfaceInActiveCategoryButton(); RenderPrefabOffsetFromGridSurfaceField(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); RenderSetPrefabOffsetFromObjectSurfaceInActiveCategoryButton(); RenderPrefabOffsetFromObjectSurfaceField(); EditorGUILayout.EndHorizontal(); }