Skip to content

Instantly share code, notes, and snippets.

@kankikuchi
Last active August 29, 2015 14:15
Show Gist options
  • Save kankikuchi/41f66053f35fea2191c1 to your computer and use it in GitHub Desktop.
Save kankikuchi/41f66053f35fea2191c1 to your computer and use it in GitHub Desktop.
変更があったファイルの中に指定したディレクトリ内のファイルがあるか【Unity】
using System;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// AssetPostprocessorの拡張クラス
/// </summary>
public class AssetPostprocessorEx : AssetPostprocessor{
/// <summary>
/// 入力されたassetsの中に、ディレクトリのパスがdirectoryNameの物はあるか
/// </summary>
protected static bool ExistsDirectoryInAssets(List<string[]> assetsList, List<string> targetDirectoryNameList){
return assetsList
.Any (assets => assets //入力されたassetsListに以下の条件を満たすか要素が含まれているか判定
.Select (asset => System.IO.Path.GetDirectoryName (asset)) //assetsに含まれているファイルのディレクトリ名だけをリストにして取得
.Intersect (targetDirectoryNameList) //上記のリストと入力されたディレクトリ名のリストの一致している物のリストを取得
.Count () > 0); //一致している物があるか
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment