private void DrawFindResult() { GUILayout.Label(">>>>>统计数量:" + findResultList.Count); FindResult delete = null; ZGUILayout.ScrollView(ref scrollPosition, () => { findResultList.ZForeachWithIndex((result, index) => { ZGUILayout.Horizontal(() => { // 序号 GUILayout.Label((index + 1).ToString(), GUILayout.Width(30)); // 选中按钮 ZGUILayout.ColorButton(result.obj.name, Color.green, () => { ZEditor.SelectObject(result.obj); }, GUILayout.MinWidth(50)); // 删除按钮 ZGUILayout.ColorButton("X", Color.red, () => { delete = result; }, GUILayout.Width(50)); }); }); }, GUILayout.ExpandWidth(true)); if (delete != null) { findResultList.Remove(delete); } }
private void HandleFindMaterialName(FileInfo file, UnityEngine.Object obj) { GameObject go = obj as GameObject; if (ZEditor.GameObjectHasMaterial(go, findMaterialName)) { Debug.Log("找到:" + file.FullName); findResultList.Add(new FindResult(file, obj)); } }
private void HandleFindComponentName(FileInfo file, UnityEngine.Object obj) { GameObject go = obj as GameObject; if (ZEditor.HasComponentIncludeChild(go, findComponentName)) { Debug.Log("找到:" + file.FullName); findResultList.Add(new FindResult(file, obj)); } }
// 判断GameObject是否含有某个名字的Material,包括子物体 public static bool GameObjectHasMaterial(GameObject obj, string materialName) { Renderer[] array = obj.GetComponentsInChildren <Renderer>(true); foreach (var each in array) { if (ZEditor.RendererHasMaterial(each, materialName)) { return(true); } } return(false); }
private void HandleFindTexture2DName(FileInfo file, UnityEngine.Object obj) { List <Texture2D> texture2DList = ZEditor.CollectTexture2DFromObject(obj); foreach (Texture2D each in texture2DList) { if (each.name == findTexture2DName) { Debug.Log("找到:" + file.FullName); findResultList.Add(new FindResult(file, obj)); break; } } }
private void HandleNextFile() { FileInfo file = files[runIndex]; string newFile = file.FullName.Substring(file.FullName.IndexOf("Assets")); UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(newFile); if (obj != null) { handleFuncDic[findType](file, obj); } if (++runIndex == runIndexMax) { running = false; EditorUtility.ClearProgressBar(); ZEditor.SelectObject(obj); } }
private void CollectAndRun() { List <FileInfo> fileList = new List <FileInfo>(); findDirectoryString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ZForeach(dir => { string fullPath = Application.dataPath + Path.DirectorySeparatorChar + dir; Debug.Log("fullPath:" + fullPath); FileInfo[] targetfiles = ZEditor.CollectFilesWithChildrenButMeta(fullPath); fileList.AddRange(targetfiles); }); files = fileList.Where(x => IsMatchFile(x)).ToArray(); Debug.Log("总目标文件数量:" + files.Length); if (files.Length > 0) { BeginRun(); } }
// 收集组件 public static List <T> CollectComponent <T>() where T : Component { List <T> resultList = new List <T>(); List <GameObject> allSceneObjs = ZEditor.GetAllObjInProject(); if (allSceneObjs.Count <= 0) { Debug.Log("请在场景中选中一个GameObject"); return(resultList); } foreach (GameObject each in allSceneObjs) { T r = each.GetComponent <T>(); if (r == null) { continue; } resultList.Add(r); } return(resultList); }