Created
March 8, 2014 07:40
-
-
Save baba-s/9426854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
public class MyAssetPostprocessor : AssetPostprocessor | |
{ | |
/// <summary> | |
/// すべてのアセットのインポートが終了した際に呼び出されます | |
/// </summary> | |
/// <param name="importedAssets">インポートされたアセットのパス</param> | |
/// <param name="deletedAssets">削除されたアセットのパス</param> | |
/// <param name="movedAssets">移動したアセットの移動後のパス</param> | |
/// <param name="movedFromPath">移動したアセットの移動前のパス</param> | |
private static void OnPostprocessAllAssets( | |
string[] importedAssets, | |
string[] deletedAssets, | |
string[] movedAssets, | |
string[] movedFromPath) | |
{ | |
foreach (var importedAsset in importedAssets) | |
{ | |
if (!IsOneByteStr(importedAsset)) | |
{ | |
if (AssetDatabase.DeleteAsset(importedAsset)) | |
{ | |
Debug.Log(importedAsset + "を削除しました"); | |
} | |
} | |
} | |
} | |
/// <summary> | |
/// 1バイト文字で構成された文字列かどうかを判定します | |
/// </summary> | |
/// <param name="str">判定対象の文字列</param> | |
/// <returns>1バイト文字のみで構成された文字列の場合 true</returns> | |
private static bool IsOneByteStr(string str) | |
{ | |
var bytes = System.Text.Encoding.GetEncoding(932).GetBytes(str); | |
return bytes.Length == str.Length; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment