First commit for private source control. Older commits available on Github.
This commit is contained in:
93
Assets/Scripts/Editor/Windows/FilePathsWindow.cs
Normal file
93
Assets/Scripts/Editor/Windows/FilePathsWindow.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System.IO;
|
||||
using BriarQueen.Data.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Editor.Windows
|
||||
{
|
||||
public class FilePathsWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("Briar Queen/IO/Open Persistent Data/Save Data")]
|
||||
private static void OpenSaveDataFolder()
|
||||
{
|
||||
OpenFolder(FilePaths.SaveDataFolder);
|
||||
}
|
||||
|
||||
[MenuItem("Briar Queen/IO/Open Persistent Data/Save Backups")]
|
||||
private static void OpenSaveBackupFolder()
|
||||
{
|
||||
OpenFolder(FilePaths.SaveBackupDataFolder);
|
||||
}
|
||||
|
||||
[MenuItem("Briar Queen/IO/Open Persistent Data/Configs")]
|
||||
private static void OpenConfigFolder()
|
||||
{
|
||||
OpenFolder(FilePaths.ConfigFolder);
|
||||
}
|
||||
|
||||
[MenuItem("Briar Queen/IO/Open Persistent Data/All Paths Window")]
|
||||
private static void ShowWindow()
|
||||
{
|
||||
var window = GetWindow<FilePathsWindow>("Persistent Data Paths");
|
||||
window.minSize = new Vector2(520f, 180f);
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Space(10f);
|
||||
EditorGUILayout.LabelField("BriarQueen Persistent Data Paths", EditorStyles.boldLabel);
|
||||
GUILayout.Space(8f);
|
||||
|
||||
DrawPathRow("Save Data", FilePaths.SaveDataFolder);
|
||||
DrawPathRow("Save Backups", FilePaths.SaveBackupDataFolder);
|
||||
DrawPathRow("Configs", FilePaths.ConfigFolder);
|
||||
|
||||
GUILayout.Space(12f);
|
||||
|
||||
if (GUILayout.Button("Open Application Persistent Data Root", GUILayout.Height(28f)))
|
||||
{
|
||||
OpenFolder(Application.persistentDataPath);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawPathRow(string label, string path)
|
||||
{
|
||||
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
|
||||
{
|
||||
EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
|
||||
EditorGUILayout.SelectableLabel(path, EditorStyles.textField, GUILayout.Height(18f));
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (GUILayout.Button("Open", GUILayout.Height(24f)))
|
||||
{
|
||||
OpenFolder(path);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Copy Path", GUILayout.Height(24f)))
|
||||
{
|
||||
EditorGUIUtility.systemCopyBuffer = path;
|
||||
Debug.Log($"Copied path: {path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OpenFolder(string folderPath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(folderPath))
|
||||
{
|
||||
Debug.LogError("Cannot open folder: path is null or empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
Directory.CreateDirectory(folderPath);
|
||||
Debug.Log($"Created folder: {folderPath}");
|
||||
}
|
||||
|
||||
EditorUtility.RevealInFinder(folderPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user