2024-12-04 23:15:05 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-08-16 14:45:44 +08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
|
|
|
|
namespace Coffee.UIExtensions.Editors
|
|
|
|
|
{
|
2024-12-04 23:15:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Remove deprecated files in old .unitypackage, after compiling.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DeprecatedRemover
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// GUIDs of deprecated files.
|
|
|
|
|
/// </summary>
|
|
|
|
|
static readonly List<string> DeprecatedFiles = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"156b57fee6ef941958e66a129ce387e2", // UICustomEffect.cs
|
2024-08-16 14:45:44 +08:00
|
|
|
|
"a4961e148a8cd4fe0b84dddc2741894a", // UICustomEffectEditor.cs
|
|
|
|
|
"7b1ed09bdf5e54042b5cd1fbe69361bf", // MaterialBundle.cs
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2024-12-04 23:15:05 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
[UnityEditor.InitializeOnLoadMethod]
|
|
|
|
|
static void RemoveFiles()
|
|
|
|
|
{
|
|
|
|
|
// The deprecated file path that exists.
|
|
|
|
|
var files = DeprecatedFiles.Select(x => AssetDatabase.GUIDToAssetPath(x))
|
|
|
|
|
.Where(x => File.Exists(x))
|
|
|
|
|
.ToArray();
|
2024-08-16 14:45:44 +08:00
|
|
|
|
|
2024-12-04 23:15:05 +08:00
|
|
|
|
if (files.Any())
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.AppendFormat("<b><color=orange>[{0}]</color></b> {1} files have been removed.\n", typeof(DeprecatedRemover).Name, files.Length);
|
2024-08-16 14:45:44 +08:00
|
|
|
|
|
2024-12-04 23:15:05 +08:00
|
|
|
|
foreach (var path in files)
|
|
|
|
|
{
|
|
|
|
|
AssetDatabase.DeleteAsset(path);
|
|
|
|
|
sb.AppendFormat(" - {0}\n", path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssetDatabase.Refresh();
|
|
|
|
|
UnityEngine.Debug.Log(sb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2024-08-16 14:45:44 +08:00
|
|
|
|
}
|