using System; using UnityEditor; using UnityEngine; using System.Collections.Generic; using System.Text.RegularExpressions; namespace BFEditor.Resource { public class LuaCheckWindow : EditorWindow { bool checkSprite; bool checkCharacter; bool checkPrefab; bool checkEffect; bool checkBackground; bool needSendMail; Vector2 scrollPos; Action checkOverAction; LuaCheckWindow() { this.titleContent = new GUIContent("Lua脚本检查"); checkOverAction = (bool result) => { if (result) { EditorUtility.DisplayDialog("提示", "检查完成,符合标准", "ok"); } }; } void OnGUI() { DrawButton(); DrawResult(); } void DrawButton() { GUILayout.Space(15); var style = new GUIStyle(GUI.skin.button); style.fontSize = 15; style.alignment = TextAnchor.MiddleCenter; if (GUILayout.Button("检查", style, GUILayout.Width(55), GUILayout.Height(26))) { CheckAll(); } GUILayout.Space(15); } void CheckAll() { LuaCheckController.CheckAll(checkOverAction); } void DrawResult() { scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(800), GUILayout.Height(660)); string currPath = ""; int count = LuaCheckController.ResultList.Count; for (int i = 0; i < count; i++) { var result = LuaCheckController.ResultList[i]; if(currPath.CompareTo(result.path) != 0) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); currPath = result.path; GUILayout.BeginHorizontal(); EditorGUILayout.SelectableLabel(result.path, GUILayout.Height(20)); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Space(40); GUILayout.Label(result.line, GUILayout.Width(60)); GUILayout.Label(result.content); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.Box("", GUI.skin.box, GUILayout.Width(794), GUILayout.Height(3)); } void OnDestroy() { LuaCheckController.Clear(); } public static void ShowLuaCheckWindow() { var window = (LuaCheckWindow)GetWindowWithRect(typeof(LuaCheckWindow), new Rect(Screen.width / 2, Screen.height / 2, 800, 820)); window.Show(); } } }