//============================================================================* // UpdateTool() //============================================================================* private void UpdateTool(cTool OldTool, cTool NewTool) { //----------------------------------------------------------------------------* // Find the NewFirearm //----------------------------------------------------------------------------* foreach (cTool CheckTool in m_DataFiles.ToolList) { //----------------------------------------------------------------------------* // See if this is the same Firearm //----------------------------------------------------------------------------* if (CheckTool.CompareTo(OldTool) == 0) { //----------------------------------------------------------------------------* // Update the current Tool record //----------------------------------------------------------------------------* CheckTool.Copy(NewTool); //----------------------------------------------------------------------------* // Update the Firearm on the Firearm tab //----------------------------------------------------------------------------* ListViewItem Item = null; foreach (ListViewItem CheckItem in m_ToolsListView.Items) { if ((CheckItem.Tag as cTool).CompareTo(CheckTool) == 0) { Item = CheckItem; break; } } if (Item != null) { try { m_ToolsListView.Items.Remove(Item); } catch { // No need to do anything here } m_ToolsListView.AddTool(CheckTool, true); } return; } } //----------------------------------------------------------------------------* // If the NewFirearm was not found, add it //----------------------------------------------------------------------------* AddTool(NewTool); }
//============================================================================* // AddTool() //============================================================================* private void AddTool(cTool Tool) { //----------------------------------------------------------------------------* // If the Tool already exists, our job is done, just exit //----------------------------------------------------------------------------* foreach (cTool CheckTool in m_DataFiles.ToolList) { if (CheckTool.CompareTo(Tool) == 0) { return; } } //----------------------------------------------------------------------------* // Otherwise, add the new firearm to the list //----------------------------------------------------------------------------* m_DataFiles.ToolList.Add(Tool); //----------------------------------------------------------------------------* // And add the new Tool to the Tool ListView //----------------------------------------------------------------------------* m_ToolsListView.AddTool(Tool, true); AddToolButton.Focus(); }
//测试 static void InitQA() { if (GUILayout.Button("一键检测工程正确性")) { CheckTool.MeterialChecker(); } }
static void TryCheckTimeEffect(GameObject go) { try { CheckTool._CheckEffectListTimeCtrlMissing(go); } catch (System.Exception ex) { Debug.LogError(ex); } }
static void TryCheckPrefab(GameObject go) { try { CheckTool._CheckGoMissingReferences(go); } catch (System.Exception ex) { Debug.LogError(ex); } }
static void TryCheckEffectScript(GameObject go) { try { CheckTool._CheckEffectOpenMissing(go); } catch (System.Exception ex) { Debug.LogError(ex); } }
static void TryCheckScript(string str, GameObject go) { try { var missingScripts = CheckTool.doCheckScriptMissing(go); if (!string.IsNullOrEmpty(missingScripts)) { Debug.LogError(string.Format("<color=red>[脚本丢失]</color>{0} \n{1}", str, missingScripts), go); } } catch (System.Exception ex) { Debug.LogError(ex); } }
static void TryCheckMatinfo(string str, GameObject go) { try { var missingMatInfo = CheckTool.GetMatMissingInfo(go); if (!string.IsNullOrEmpty(missingMatInfo)) { Debug.LogError(string.Format("<color=red>[材质丢失]</color> {0}\n{1}", str, missingMatInfo), go); } } catch (System.Exception ex) { Debug.LogError(ex); } }
//[MenuItem("Laz/Tools/工程正确性检查(特效脚本相关)", false, 22)] public static void CheckEffectScript() { CheckTool.ClearConsole(); BeginWriteLog(); GetData(); if (strs != null) { foreach (var str in strs) { _CheckEffectScript(str); } } ClearData(); EndWriteLog(); EditorUtility.DisplayDialog("检查完毕", "请通过Window/Console打开输出日志查看详细数据,也可以查看项目根目录的日志", "OK"); }
//============================================================================* // OnAddTool() //============================================================================* protected void OnAddTool(object sender, EventArgs args) { //----------------------------------------------------------------------------* // Start the dialog //----------------------------------------------------------------------------* Cursor = Cursors.WaitCursor; cToolForm ToolForm = new cToolForm(null, m_DataFiles); Cursor = Cursors.Default; if (ToolForm.ShowDialog() == DialogResult.OK) { //----------------------------------------------------------------------------* // Get the new Tool Data //----------------------------------------------------------------------------* cTool NewTool = ToolForm.Tool; m_DataFiles.Preferences.LastTool = ToolForm.Tool; m_ToolsListView.Focus(); //----------------------------------------------------------------------------* // See if the Tool already exists //----------------------------------------------------------------------------* foreach (cTool CheckTool in m_DataFiles.ToolList) { if (CheckTool.CompareTo(NewTool) == 0) { return; } } AddTool(NewTool); } UpdateToolsTabButtons(); }
static void TryCheckMissAnimation(string str, GameObject go) { try { var missingAnimation = CheckTool.GetAnimationBug(go); if (!string.IsNullOrEmpty(missingAnimation)) { if (!CheckTool.isWarningLog) { Debug.LogError(string.Format("<color=red>[动画组件]</color> {0}\n{1}", str, missingAnimation), go); } else { Debug.LogWarning(string.Format("<color=red>[动画组件]</color> {0}\n{1}", str, missingAnimation), go); } } } catch (System.Exception ex) { Debug.LogError(ex); } }
//============================================================================* // AddTool() //============================================================================* public bool AddTool(cTool Tool, bool fCountOnly = false) { m_nImportCount++; foreach (cTool CheckTool in this) { if (CheckTool.CompareTo(Tool) == 0) { m_nUpdateCount += CheckTool.Append(Tool, fCountOnly); return(false); } } if (!fCountOnly) { Add(Tool); } m_nNewCount++; return(true); }
//程序 static void InitProrgammer() { GUIStyle aa = new GUIStyle(); aa.normal.background = null; //这是设置背景填充的 aa.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 aa.fontSize = 10; GUILayout.Label("工程正确性(GO对象引用丢失)", aa); if (GUILayout.Button("一键检测工程正确性")) { CheckTool.MeterialChecker(); } #region Go对象检查工具 GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUIStyle bb = new GUIStyle(); bb.normal.background = null; //这是设置背景填充的 bb.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 bb.fontSize = 10; GUILayout.Label("工程正确性(GO对象引用丢失)", bb); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); goRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(goRect, goPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { goPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("GO对象引用丢失")) { if (!string.IsNullOrEmpty(goPath)) { string cPath = ConversionPath(goPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Prefab", new string[] { cPath }); CheckTool._CheckFindMissingReferences(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } #endregion #region 工程正确性(删除角色时装和武器预制体空的Animator) GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUIStyle cc = new GUIStyle(); cc.normal.background = null; //这是设置背景填充的 cc.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 cc.fontSize = 10; GUILayout.Label("删除角色时装和武器预制体空的Animator", cc); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); playerAnimator = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(playerAnimator, animatorPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { animatorPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("工程正确性(删除角色时装和武器预制体空的Animator)")) { if (!string.IsNullOrEmpty(animatorPath)) { string cPath = ConversionPath(animatorPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Prefab", new string[] { cPath }); CheckTool._PlayerBadAnimatorDeleter(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } #endregion #region 特效检查 GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUIStyle dd = new GUIStyle(); dd.normal.background = null; //这是设置背景填充的 dd.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 dd.fontSize = 10; GUILayout.Label("工程正确性(检查特效丢失)", dd); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); effectRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(effectRect, effectPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { effectPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("检查特效丢失")) { if (!string.IsNullOrEmpty(effectPath)) { string cPath = ConversionPath(effectPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Prefab", new string[] { cPath }); CheckTool._CheckEffectScriptMissing(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } #endregion #region prefab材质检查 GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUIStyle ee = new GUIStyle(); ee.normal.background = null; //这是设置背景填充的 ee.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 ee.fontSize = 10; GUILayout.Label("工程正确性(prefab材质)", ee); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); prefabMaterialRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(prefabMaterialRect, prefabMaterialpath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { prefabMaterialpath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("prefab材质")) { if (!string.IsNullOrEmpty(prefabMaterialpath)) { string cPath = ConversionPath(prefabMaterialpath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Prefab", new string[] { cPath }); CheckTool._CheckFindMissingReferences(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } #endregion #region 脚本丢失以及音效脚本 GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUIStyle ff = new GUIStyle(); ff.normal.background = null; //这是设置背景填充的 ff.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 ff.fontSize = 10; GUILayout.Label("工程正确性(脚本丢失以及音效脚本)", ff); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); scriptMissingRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(scriptMissingRect, scriptMissingPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { scriptMissingPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("脚本丢失以及音效脚本")) { if (!string.IsNullOrEmpty(scriptMissingPath)) { string cPath = ConversionPath(scriptMissingPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Prefab", new string[] { cPath }); CheckTool._CheckScriptMissing(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } #endregion #region 动画丢失 GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUIStyle gg = new GUIStyle(); gg.normal.background = null; //这是设置背景填充的 gg.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 gg.fontSize = 10; GUILayout.Label("工程正确性(动画丢失)", gg); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); prefabMissingRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(prefabMissingRect, prefabAnimatorPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { prefabAnimatorPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("动画丢失)")) { if (!string.IsNullOrEmpty(prefabAnimatorPath)) { string cPath = ConversionPath(prefabAnimatorPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Prefab", new string[] { cPath }); CheckTool._CheckAnimationException(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUIStyle hh = new GUIStyle(); hh.normal.background = null; //这是设置背景填充的 hh.normal.textColor = new Color(1, 0, 0); //设置字体颜色的 hh.fontSize = 10; GUILayout.Label("根据路径提供检测资源大小", hh); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); assetRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(assetRect, assetPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { assetPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("检测资源大小")) { if (!string.IsNullOrEmpty(assetPath)) { string cPath = ConversionPath(assetPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Texture", new string[] { cPath }); CheckTool._CheckAssetsSize(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } #endregion }
//美术 static void InitAritstTool() { if (GUILayout.Button("贴图工具", GUILayout.Height(35f))) { window.Close(); Indra.TextureTool.TextureListWindow.OpenTexWindow(); } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUILayout.Label("请在Project界面选择文件或目录!"); GUILayout.BeginHorizontal(); if (GUILayout.Button("刷新模型顶部到底部的顶点色", GUILayout.Width(200), GUILayout.Height(30))) { CharacterGlintVertexColorTool.Open(); } GUILayout.EndHorizontal(); GUILayout.Label("禁用模型读写"); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); modelRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(modelRect, modelPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { modelPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("禁用模型读写")) { if (!string.IsNullOrEmpty(modelPath)) { string cPath = ConversionPath(modelPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:model", new string[] { cPath }); FbxSimplify.CheckVertexColor(prefabs); FbxSimplify.CheckMultiUVs(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUILayout.Label("根据路径提供检测资源大小"); GUILayout.BeginHorizontal(); GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:"); assetRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true)); GUI.TextField(assetRect, assetPath); if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30))) { assetPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty); } GUILayout.EndHorizontal(); if (GUILayout.Button("检测资源大小")) { if (!string.IsNullOrEmpty(assetPath)) { string cPath = ConversionPath(assetPath); if (string.IsNullOrEmpty(cPath)) { return; } string[] prefabs = AssetDatabase.FindAssets("t:Texture", new string[] { cPath }); CheckTool._CheckAssetsSize(prefabs); } else { EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK"); } } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { #if UsingSyscAB CheckAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); #endif var titleByte = System.Convert.FromBase64String(_title); var title = System.Text.Encoding.UTF8.GetString(titleByte); int current = 1; int total = importedAssets.Length; //bool anyFuckingError = false; CheckTool.GetWhiteList(); //待Fgui 特效部分确认后修改检查方式 //CheckEffectTool.GetData() foreach (string str in importedAssets) { if (str.ToLower().Contains(".fbx")) { continue; } if (str.Contains("Assets/StreamingAssets")) { continue; } EditorUtility.DisplayProgressBar(title, str, (float)current / total); var obj = AssetDatabase.LoadAssetAtPath <Object>(str); try { CheckTool.CheckAssetsSize(obj); } catch (System.Exception ex) { Debug.LogWarning(string.Format("{0} \n {1}", obj.name, ex)); } if (obj is GameObject) { if (obj == null) { Debug.LogError("Loading Asset Failed!!!!!!! \n Path: " + str); } var go = obj as GameObject; NowIdentiyCheck(str, go); //anyFuckingError |= (effectListTimeCtrlMissing | checkEffectOpenMissing | nameError); } current++; } EditorUtility.ClearProgressBar(); //foreach (string str in deletedAssets) //{ // Debug.Log("Deleted Asset: " + str); //} for (int i = 0; i < movedAssets.Length; i++) { Debug.LogWarning("从位置: " + movedFromAssetPaths[i] + "\n移动到: " + movedAssets[i] + " <color=red>[您移动了文件,请确保您没有手滑]</color>"); } //if (anyFuckingError) //{ // EditorUtility.DisplayDialog("警告", "有资源错误,请检查Console日志!", "确定"); //} CheckEffectTool.ClearData(); CheckTool.ClearWhiteList(); }
private void tsmCheck_Click(object sender, EventArgs e) { CheckTool ckTool = new CheckTool(); ckTool.ShowDialog(); }