public void ExtractFromPrefab(Prefab prefab, float previewScale) { Texture2D previewTexture = PrefabPreviewTextureCache.Get().GetPrefabPreviewTexture(prefab); // Establish size _buttonWidth = (previewTexture != null ? previewTexture.width : EditorGUILayoutEx.DefaultPrefabPreviewSize) * previewScale; _buttonHeight = (previewTexture != null ? previewTexture.height : EditorGUILayoutEx.DefaultPrefabPreviewSize) * previewScale; // Establish GUI content _buttonContent = new GUIContent(); _buttonContent.image = previewTexture; _buttonContent.tooltip = prefab.Name; }
private void PerformPrefabsToCategoryDropOperation(PrefabCategory prefabCategory) { var prefabsDropData = new PrefabsToCategoryDropOperationData(prefabCategory); prefabsDropData.FromLastDropOperation(); if (prefabsDropData.ValidDroppedPrefabs.Count != 0) { var prefabsDropOperation = new PrefabsToCategoryDropOperation(prefabsDropData); prefabsDropOperation.Perform(); PrefabPreviewTextureCache.Get().GeneratePreviewsForPrefabCollection(prefabsDropData.ValidDroppedPrefabs, true); } }
public static void LoadConfig(string fileName) { if (string.IsNullOrEmpty(fileName)) { return; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); UndoEx.RecordForToolAction(PrefabTagDatabase.Get()); PrefabTagDatabase.Get().RemoveAndDestroyAllPrefabTags(); XmlNodeList prefabTagsDatabaseNodes = xmlDoc.SelectNodes("//" + PrefabConfigXMLInfo.PrefabTagDatabaseNode); if (prefabTagsDatabaseNodes.Count != 0) { ReadAllPrefabTags(prefabTagsDatabaseNodes[0]); } UndoEx.RecordForToolAction(PrefabCategoryDatabase.Get()); PrefabCategoryDatabase.Get().RemoveAndDestroyAllPrefabCategories(true); XmlNodeList prefabCategoryDatabaseNodes = xmlDoc.SelectNodes("//" + PrefabConfigXMLInfo.PrefabCategoryDatabaseNode); if (prefabCategoryDatabaseNodes.Count != 0) { ReadAllPrefabCategories(prefabCategoryDatabaseNodes[0]); } PrefabPreviewTextureCache.Get().GeneratePreviewForAllPrefabCategories(true); PrefabCategory firstNonEmptyCategory = PrefabCategoryDatabase.Get().GetFirstNonEmptyCategory(); if (firstNonEmptyCategory != null) { PrefabCategoryDatabase.Get().SetActivePrefabCategory(firstNonEmptyCategory); } XmlNodeList prefabScrollViewLookAndFeelNodes = xmlDoc.SelectNodes("//" + PrefabConfigXMLInfo.PrefabScrollViewLookAndFeelNode); if (prefabScrollViewLookAndFeelNodes.Count != 0) { ReadPrefabScrollViewLookAndFeel(prefabScrollViewLookAndFeelNodes[0]); } }
private GUIContent GetContentForTileConnectionTypePreviewButton() { var content = new GUIContent(); content.text = ""; if (_settings.Prefab == null) { content.tooltip = "Drop a prefab here to associate it with this tile connection type."; content.image = TextureCache.Get().GetTextureAtRelativePath(ObjectPlacementPathTileConnectionTypeTexturePaths.GetRelativeTexturePathForTileConnectionType(_settings.TileConnectionType)); } else { content.tooltip = _settings.Prefab.Name; content.image = PrefabPreviewTextureCache.Get().GetPrefabPreviewTexture(_settings.Prefab); } return(content); }
private void PerformPrefabFoldersToCategoryDropOperation(PrefabCategory prefabCategory) { var prefabFoldersDropData = new PrefabFoldersToCategoryDropData(prefabCategory, PrefabFoldersDropSettings.ProcessSubfolders); prefabFoldersDropData.FromLastDropOperation(); var dropDataCollection = prefabFoldersDropData.PrefabFoldersDropDataCollection; if (dropDataCollection.Count != 0) { var prefabFoldersDropOperation = new PrefabFoldersToCategoryDropOperation(prefabFoldersDropData); prefabFoldersDropOperation.Perform(); foreach (var dropData in dropDataCollection) { PrefabPreviewTextureCache.Get().GeneratePreviewsForPrefabCollection(dropData.ValidPrefabs, true); } } }
private GUIContent GetContentForPrefabPreviewBox() { var content = new GUIContent(); content.text = ""; if (_brushElement.Prefab == null) { content.text = "(No prefab)"; content.tooltip = "Drop a prefab here to associate it with this brush element."; content.image = null; } else { content.tooltip = _brushElement.Prefab.Name; content.image = PrefabPreviewTextureCache.Get().GetPrefabPreviewTexture(_brushElement.Prefab); } return(content); }
private void OnEnable() { _octave = target as Octave3DWorldBuilder; _octave.OnInspectorEnabled(); // Note: Just ensure that the Inspector will be redrawn on Undo/Redo. Undo.undoRedoPerformed -= Repaint; Undo.undoRedoPerformed += Repaint; // Let the world know that the tool was selected :) ToolWasSelectedMessage.SendToInterestedListeners(); ToolSupervisor.Get().RemoveNullPrefabReferences(); if (PrefabPreviewTextureCache.Get().NumPreviews == 0) { PrefabPreviewTextureCache.Get().GeneratePreviewForAllPrefabCategories(true); } _octave.RepaintAllEditorWindows(); }
public void RemoveNullPrefabReferences() { if (PrefabPreviewTextureCache.Get() == null) { return; } if (PrefabCategoryDatabase.Get() == null) { return; } if (DecorPaintObjectPlacementBrushDatabase.Get() == null) { return; } if (ObjectPlacement.Get() == null) { return; } PrefabPreviewTextureCache.Get().DestroyTexturesForNullPrefabEntries(); PrefabCategoryDatabase.Get().RemoveNullPrefabEntriesInAllCategories(); DecorPaintObjectPlacementBrushDatabase.Get().RemoveNullPrefabsFromAllBrushElements(); ObjectPlacement.Get().PathObjectPlacement.PathSettings.TileConnectionSettings.RemoveNullPrefabReferences(); }