diff --git a/Client/Assets/Editor/ModelTranslatorMenu.cs b/Client/Assets/Editor/ModelTranslatorMenu.cs index b47de9e5..0e7f6079 100644 --- a/Client/Assets/Editor/ModelTranslatorMenu.cs +++ b/Client/Assets/Editor/ModelTranslatorMenu.cs @@ -60,6 +60,8 @@ namespace XGame.Editor { EditorApplication.update -= OnUpdate; SavePrefs(); + if (_proc != null) + UnityEngine.Debug.LogWarning("[模型转换] 窗口关闭或脚本重编译中止了正在进行的转换"); KillProc(); } @@ -177,7 +179,7 @@ namespace XGame.Editor { FileName = _pythonPath, Arguments = string.Format( - "\"{0}\" \"{1}\" -o \"{2}\" --max-size {3} --blender \"{4}\"", + "-u \"{0}\" \"{1}\" -o \"{2}\" --max-size {3} --blender \"{4}\"", script, _fbxPath, Path.Combine(RepoRoot, outRel), _maxSize, _blenderPath), WorkingDirectory = RepoRoot, UseShellExecute = false, @@ -267,10 +269,17 @@ namespace XGame.Editor private void KillProc() { if (_proc == null) return; - try { if (!_proc.HasExited) _proc.Kill(); } + try + { + // 用 taskkill /T 连 blender 子进程一起杀(Mono BCL 无 Kill(tree) 重载) + if (!_proc.HasExited) + Process.Start(new ProcessStartInfo("taskkill", "/PID " + _proc.Id + " /T /F") + { UseShellExecute = false, CreateNoWindow = true }); + } catch { /* 进程可能刚好退出 */ } _proc.Dispose(); _proc = null; + lock (_lock) _pending.Clear(); // 丢弃残留输出,避免插在 [已取消] 之后 } } }