Skip to content

Instantly share code, notes, and snippets.

@LuviKunG
Last active February 10, 2025 02:34
Show Gist options
  • Save LuviKunG/2c6bec44a37a3499d01082015d1f9bc9 to your computer and use it in GitHub Desktop.
Save LuviKunG/2c6bec44a37a3499d01082015d1f9bc9 to your computer and use it in GitHub Desktop.
Unity Editor Menu Tweaks for easy access to persistent folder and project assets folder.
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace LuviKunG
{
/// <summary>
/// Unity Editor Menu Extension.
/// </summary>
public static class UnityEditorMenuExtension
{
#region Edit
#if UNITY_EDITOR_WIN
/// <summary>
/// Open Persistent Data Path. (Ctrl+Shift+Q)
/// </summary>
#elif UNITY_EDITOR_OSX
/// <summary>
/// Open Persistent Data Path. (Cmd+Shift+Q)
/// </summary>
#endif
[MenuItem("Edit/Open Persistent Data Path %#q", priority = 211)]
public static void OpenPersistentDataPath()
{
Application.OpenURL(Application.persistentDataPath);
}
#if UNITY_EDITOR_WIN
/// <summary>
/// Open Project Asset Path. (Ctrl+Shift+Q)
/// </summary>
#elif UNITY_EDITOR_OSX
/// <summary>
/// Open Project Asset Path. (Cmd+Shift+Q)
/// </summary>
#endif
[MenuItem("Edit/Open Project Asset Path %#w", priority = 212)]
public static void OpenProjectAssetPath()
{
Application.OpenURL(Application.dataPath);
}
#endregion
#region Assets
#if UNITY_EDITOR_WIN
/// <summary>
/// Force Reserialize Assets. (Ctrl+Shift+R)
/// </summary>
#elif UNITY_EDITOR_OSX
/// <summary>
/// Force Reserialize Assets. (Cmd+Shift+R)
/// </summary>
#endif
[MenuItem("Assets/Force Reserialize Assets %#r", priority = 121)]
public static void ForceReserializeAssets()
{
if (Selection.count > 0)
{
List<string> paths = new List<string>();
foreach (var obj in Selection.objects)
{
var path = AssetDatabase.GetAssetPath(obj);
if (string.IsNullOrEmpty(path))
continue;
paths.Add(path);
}
AssetDatabase.ForceReserializeAssets(paths, ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata);
}
else
{
if (EditorUtility.DisplayDialog("Force Reserialize Assets", "This will force reserialize all assets in the project. Are you sure?", "Yes", "No"))
{
AssetDatabase.ForceReserializeAssets();
}
}
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment