46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using UnityEditor;
|
|
|
|
namespace Module.NavigationTool.Editor.History
|
|
{
|
|
internal sealed class HistoryListPostProcess : AssetPostprocessor
|
|
{
|
|
private static bool IGNORE_NEXT_SELECTION_CHANGE;
|
|
|
|
static HistoryListPostProcess()
|
|
{
|
|
Selection.selectionChanged += OnSelectionChanged;
|
|
}
|
|
|
|
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
|
{
|
|
bool isDirty = deletedAssets.Length != 0 ||
|
|
movedAssets.Length != 0 ||
|
|
movedFromAssetPaths.Length != 0;
|
|
|
|
if (isDirty && HistoryUtility.IsLoaded())
|
|
HistoryUtility.RefreshAll();
|
|
}
|
|
|
|
private static void OnSelectionChanged()
|
|
{
|
|
if (Selection.assetGUIDs == null)
|
|
return;
|
|
|
|
if (IGNORE_NEXT_SELECTION_CHANGE)
|
|
{
|
|
IGNORE_NEXT_SELECTION_CHANGE = false;
|
|
}
|
|
else
|
|
{
|
|
HistoryList historyList = HistoryUtility.GetHistoryList();
|
|
historyList.AddRange(Selection.assetGUIDs);
|
|
HistoryGUIUtility.Repaint();
|
|
}
|
|
}
|
|
|
|
public static void IgnoreNextSelectionChange()
|
|
{
|
|
IGNORE_NEXT_SELECTION_CHANGE = true;
|
|
}
|
|
}
|
|
} |