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 DrawFindDirectory() { EditorGUILayout.LabelField("包括目录:"); findDirectoryString = EditorGUILayout.TextField(findDirectoryString); ZGUILayout.Button("Save", () => { EditorPrefs.SetString(KEY_findDirectoryString, findDirectoryString); }); }
// 查找目标类型 private void DrawFindTarget() { EditorGUILayout.LabelField("目标类型:"); ZGUILayout.Horizontal(() => { findPrefab = EditorGUILayout.Toggle("Prefab", findPrefab, GUILayout.ExpandWidth(false)); findMaterial = EditorGUILayout.Toggle("Material", findMaterial, GUILayout.ExpandWidth(false)); }); }
// 查找Component private void DrawFindComponentName() { findComponentName = EditorGUILayout.TextField("Component:", findComponentName); if (!running && !string.IsNullOrEmpty(findComponentName)) { List <Type> ret = projectScriptList.Where(x => x.Name.ToLower().Contains(findComponentName.ToLower())).ToList(); foreach (Type str in ret) { string className = str.Name; // 有相同的 if (className.ToLower().Equals(findComponentName.ToLower())) { findComponentName = className; break; } // 相似的 GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(className, GUILayout.ExpandWidth(true)); // 绿色按钮 GUI.backgroundColor = Color.green; if (GUILayout.Button("Select", GUILayout.MinWidth(50))) { findComponentName = className; break; } GUI.backgroundColor = Color.white; } GUILayout.EndHorizontal(); } } ZGUILayout.ColorButton(EditorGUIUtility.IconContent("ViewToolZoom"), Color.green, () => { if (string.IsNullOrEmpty(findComponentName)) { return; } findType = FindType.ComponentName; CollectAndRun(); }); }
// 查找Object private void DrawFindObject() { ZGUILayout.Horizontal(() => { findObject = EditorGUILayout.ObjectField("Object:", findObject, typeof(UnityEngine.Object)); ZGUILayout.ColorButton(EditorGUIUtility.IconContent("ViewToolZoom"), Color.green, () => { if (findObject == null) { return; } findType = FindType.Object; CollectAndRun(); }, GUILayout.Width(70)); }); }
// 绘制查找项 private string DrawCommonFindItem(string findContent, string label, FindType btnFindType) { ZGUILayout.Horizontal(() => { findContent = EditorGUILayout.TextField(label, findContent); ZGUILayout.ColorButton(EditorGUIUtility.IconContent("ViewToolZoom"), Color.green, () => { if (string.IsNullOrEmpty(findContent)) { return; } findType = btnFindType; CollectAndRun(); }, GUILayout.Width(70)); }); return(findContent); }