Skip to content

Instantly share code, notes, and snippets.

@mob-sakai
Last active September 5, 2018 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mob-sakai/1a01e2d670d4402f79bf1b78ae42d7e6 to your computer and use it in GitHub Desktop.
Save mob-sakai/1a01e2d670d4402f79bf1b78ae42d7e6 to your computer and use it in GitHub Desktop.
古い.unitypackageでインポートしたファイルを削除する(GUID指定)
using System.Collections;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace Coffee.UIExtensions.UIEffectDepricated
{
/// <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
"a4961e148a8cd4fe0b84dddc2741894a", // UICustomEffectEditor.cs
};
#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();
if (files.Any())
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("<b><color=orange>[DeprecatedRemover]</color></b> {0} files have been removed.\n", files.Length);
foreach (var path in files)
{
AssetDatabase.DeleteAsset(path);
sb.AppendFormat(" - {0}\n", path);
}
AssetDatabase.Refresh();
UnityEngine.Debug.Log(sb);
}
}
#endif
}
}
@mob-sakai
Copy link
Author

unitypackageのバージョン違いによるコンフリクトを防ぐ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment