Esempio n. 1
0
        public static SettingsProvider CreateLuaCheckSettingProvider()
        {
            var provider = new SettingsProvider("Project/LuaCheckSetting", SettingsScope.Project)
            {
                label      = "Setup Lua Check",
                guiHandler = search => {
                    var settings   = LuaCheckSetting.GetSerializedSettings();
                    var activeProp = settings.FindProperty("m_active");
                    EditorGUILayout.PropertyField(activeProp);

                    EditorGUILayout.BeginHorizontal();
                    GUI.enabled = false;
                    var execPathProp = settings.FindProperty("m_luaCheckExecPath");
                    EditorGUILayout.PropertyField(execPathProp);
                    GUI.enabled = true;
                    if (GUILayout.Button("Open", "LargeButtonRight", GUILayout.Width(80)))
                    {
                        var selected = EditorUtility.OpenFilePanel("Select LuaCheck.exe", "", "exe");
                        execPathProp.stringValue = selected;
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.PropertyField(settings.FindProperty("m_maxLineLength"));
                    settings.ApplyModifiedProperties();
                }
            };

            return(provider);
        }
Esempio n. 2
0
        private static void ExecLuaCheck(string luaPath)
        {
            luaPath = luaPath.Replace('\\', '/');
            var index       = luaPath.IndexOf("Lua/", StringComparison.InvariantCulture);
            var projectPath = luaPath.Substring(index + 4, luaPath.Length - index - 4 - 4);

            LuaClassEditorFactory.ReloadDescriptor(projectPath);
            var setting = LuaCheckSetting.GetOrCreateSettings();

            if (setting.Active && !string.IsNullOrEmpty(setting.LuaCheckExecPath) && File.Exists(setting.LuaCheckExecPath))
            {
                var proc = new Process {
                    StartInfo = new ProcessStartInfo {
                        FileName               = setting.LuaCheckExecPath,
                        Arguments              = $"{luaPath} --no-global --max-line-length {setting.MaxLineLength}",
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow         = true
                    }
                };
                proc.Start();
                var builder = new StringBuilder(1024);
                while (!proc.StandardOutput.EndOfStream)
                {
                    var line = proc.StandardOutput.ReadLine();
                    builder.AppendLine(line);
                }

                Debug.Log(builder.ToString());
            }
        }