SamsonGame/Assets/Editor/ChangedConfigsProcessor.cs

50 lines
1.2 KiB
C#
Raw Permalink Normal View History

2021-12-29 20:50:11 +03:00
using System.Collections.Generic;
using UnityEditor;
public class ChangedConfigsProcessor : AssetPostprocessor
{
private static void OnPostprocessAllAssets(
string[] imported,
string[] deleted,
string[] moved,
string[] moved_from_paths
)
{
var accum = new List<string>(10);
FilterConfigFiles(imported, accum);
FilterConfigFiles(deleted, accum);
FilterConfigFiles(moved, accum);
FilterConfigFiles(moved_from_paths, accum);
if (accum.Count == 0)
return;
//TODO: animate it properly someday
EditorUtility.DisplayProgressBar("Building configs", "In progress...", 0.3f);
try
{
BuildUtils.Urun();
}
finally
{
EditorUtility.ClearProgressBar();
}
}
private static void FilterConfigFiles(IEnumerable<string> paths, ICollection<string> accum)
{
const string metagenConf = ".conf.js";
const string bhlConf = ".bhl";
foreach (string path in paths)
{
if (accum.Contains(path))
continue;
if (path.EndsWith(metagenConf) || path.EndsWith(bhlConf))
accum.Add(path);
}
}
}