public void CheckAssetBundleName(string is_atlas_model, Dictionary <string, List <string> > groupDi) { var checkerFilters = config.CheckerFilters; //Debug.LogError("checkffilters" + checkerFilters); if (checkerFilters == null || checkerFilters.Count == 0) { var di = new DirectoryInfo(assetsPath); CheckAddressablePath(di, is_atlas_model, groupDi); //Logger.LogError("==========CheckAssetBundleName====5=====" + assetsPath); } else { foreach (var checkerFilter in checkerFilters) { var relativePath = assetsPath; if (!string.IsNullOrEmpty(checkerFilter.RelativePath)) { relativePath = Path.Combine(assetsPath, checkerFilter.RelativePath); } var groupName = config.PackagePath.Replace("/", "_").Replace("\\", "_").ToLower(); string[] objGuids = AssetDatabase.FindAssets(checkerFilter.ObjectFilter, new string[] { relativePath }); foreach (var guid in objGuids) { AASUtility.AddAssetToGroup(guid, groupName); } } } }
public static void SingleFileAddress(string group, string path) { string relativePath = path.Substring(path.IndexOf("Assets\\")); Logger.Log(relativePath); AASUtility.AddAssetToGroup(AssetDatabase.AssetPathToGUID(relativePath), group); }
public void CheckAssetBundleName() { var checkerFilters = config.CheckerFilters; if (checkerFilters == null || checkerFilters.Count == 0) { CheckAddressablePath(new DirectoryInfo(assetsPath)); } else { foreach (var checkerFilter in checkerFilters) { var relativePath = assetsPath; if (!string.IsNullOrEmpty(checkerFilter.RelativePath)) { relativePath = Path.Combine(assetsPath, checkerFilter.RelativePath); } var groupName = config.PackagePath.Replace("/", "-").ToLower(); string[] objGuids = AssetDatabase.FindAssets(checkerFilter.ObjectFilter, new string[] { relativePath }); foreach (var guid in objGuids) { AASUtility.AddAssetToGroup(guid, groupName); } } } }
/// <summary> /// mark 单个文件 /// </summary> /// <param name="path"></param> static void MarkedSingleFile(string path) { //Logger.LogError("file path:" + path); string temp_path = path.Replace("Assets/AssetsPackage/", ""); //Logger.LogError("temp_path:" + temp_path); string[] path_list = temp_path.Split('/'); string groupName = "tempgroup"; if (path_list.Length > 1) { string validation_path = "Assets/AssetsPackage/" + path_list[0] + "/" + path_list[1]; if (path_list.Length > 2)//是文件,没有二级目录 { //Logger.LogError("二级目录:" + path); groupName = path_list[0].ToLower() + "_" + path_list[1].ToLower(); } else { //Logger.LogError("一级目录 :" + path); groupName = path_list[0].ToLower(); } var guid = UnityEditor.AssetDatabase.AssetPathToGUID(path); AASUtility.AddAssetToGroup(guid, groupName); } else { Debug.LogError("file path error:" + path); } }
public static void AddImportAssetToaddressable(string path) { string dir = Path.GetDirectoryName(path); int index = dir.IndexOf(Assets_Package + Path.DirectorySeparatorChar); if (index < 0) { return; } dir = dir.Substring(index + (Assets_Package + Path.DirectorySeparatorChar).Length); index = dir.IndexOf(Path.DirectorySeparatorChar); if (index > 0) { index = dir.IndexOf(Path.DirectorySeparatorChar, index + 1); if (index > 0) { dir = dir.Substring(0, index); } } string groupName = dir.ToLower().Replace(Path.DirectorySeparatorChar, '_'); string guid = AssetDatabase.AssetPathToGUID(path); AASUtility.AddAssetToGroup(guid, groupName); }
static public bool AddGroup(string asset) { var dir = System.IO.Path.GetDirectoryName(asset); //グループに含めていいかのチェック //ディレクトリとエディターディレクトリのアセットは含めない if (System.IO.Directory.Exists(asset)) { return(false); } if (dir.Contains(editorDir)) { return(false); } //アドレス名を求める計算 var filename = System.IO.Path.GetFileName(asset); dir = dir.Replace(assetRoot, ""); string group = dir.Replace(System.IO.Path.DirectorySeparatorChar, '_'); var address = group + "_" + System.IO.Path.GetFileNameWithoutExtension(asset); AASUtility.AddAssetToGroup(AssetDatabase.AssetPathToGUID(asset), group, address); return(true); }
public void CheckAddressablePath(DirectoryInfo di) { var groupName = config.PackagePath.Replace("/", "-").ToLower(); FileInfo[] fis = di.GetFiles(); foreach (FileInfo f in fis) { if (f.Extension.Equals(".meta")) { continue; } string relativePath = f.FullName.Substring(f.FullName.IndexOf("\\Assets\\") + 1); AASUtility.AddAssetToGroup(AssetDatabase.AssetPathToGUID(relativePath), groupName); } DirectoryInfo[] dis = di.GetDirectories(); foreach (DirectoryInfo d in dis) { CheckAddressablePath(d); } }
private static void RunAllCheckersTask() { ThreadPars[] threadParses = new ThreadPars[ThreadCount]; for (int index = 0; index < ThreadCount; index++) { threadParses[index] = new ThreadPars(); } var guids = AssetDatabase.FindAssets("t:AddressableDispatcherConfig", new string[] { AddressableInspectorUtils.DatabaseRoot }); var length = guids.Length; var count = 0; foreach (var guid in guids) { count++; var assetPath = AssetDatabase.GUIDToAssetPath(guid); var config = AssetDatabase.LoadAssetAtPath <AddressableDispatcherConfig>(assetPath); config.Load(); int index = count % ThreadCount; threadParses[index].ChildDataList.Add(config); threadParses[index].is_atlas_model = EditorUserSettings.GetConfigValue(AddressableTools.is_atlas_model); } List <Task <Dictionary <string, List <string> > > > taskList = new List <Task <Dictionary <string, List <string> > > >(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[0])); })); taskList[0].Start(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[1])); })); taskList[1].Start(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[2])); })); taskList[2].Start(); taskList.Add(new Task <Dictionary <string, List <string> > >(() => { return(ThreadFind(threadParses[3])); })); taskList[3].Start(); for (int i = 0; i < ThreadCount; i++) { taskList[i].Wait(); } //Logger.LogError("=======over========="); Dictionary <string, UnityEditor.AddressableAssets.Settings.AddressableAssetGroup> groupsDic = new Dictionary <string, UnityEditor.AddressableAssets.Settings.AddressableAssetGroup>(); for (int i = 0; i < ThreadCount; i++) { foreach (var keyvalue in taskList[i].Result) { keyvalue.Value.Sort(); foreach (var pathStr in keyvalue.Value) { //Logger.LogError("path:" + pathStr + " groupName:" + keyvalue.Key); if (!groupsDic.ContainsKey(keyvalue.Key)) { groupsDic.Add(keyvalue.Key, AASUtility.CreateGroup(keyvalue.Key)); } UnityEditor.AddressableAssets.Settings.AddressableAssetEntry temp_entry = null; var s = AASUtility.GetSettings(); foreach (UnityEditor.AddressableAssets.Settings.AddressableAssetGroup group in s.groups) { if (group == null) { continue; } foreach (UnityEditor.AddressableAssets.Settings.AddressableAssetEntry entry in group.entries) { //Logger.LogError("entry.AssetPath:" + entry.AssetPath + " pathstr:" + pathStr + " group.name:" + group.name + " keyvalue.key:" + keyvalue.Key); if ((entry.AssetPath.Replace('\\', '/') == pathStr.Replace('\\', '/')) && (group.name == keyvalue.Key)) { //Logger.LogError("============temp_entry=====================" + pathStr); temp_entry = entry; } } } if (temp_entry == null) { //Logger.LogError("=================================" + pathStr); var guid = AssetDatabase.AssetPathToGUID(pathStr); AASUtility.AddAssetToGroup(guid, keyvalue.Key); } } } } AssetDatabase.Refresh(); }
public static void SingleFileAddress(string group, string path) { string relativePath = path.Substring(path.IndexOf("Assets" + Path.DirectorySeparatorChar)); AASUtility.AddAssetToGroup(AssetDatabase.AssetPathToGUID(relativePath), group); }