From 83cfc8c709f0074eea3f5da2ada7134d3467a254 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Sun, 9 Jan 2022 21:42:18 -0800 Subject: [PATCH] Removed some logs --- .../Editor/EcsIdlPackagesPostprocessor.cs | 7 ++--- .../Editor/EcsIdlUnitySyncDebugWindow.cs | 6 ++++- .../Editor/Importer/EcsIdlImporter.cs | 26 +++++++++++++++++-- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/packages/com.seaube.ecs-idl/Editor/EcsIdlPackagesPostprocessor.cs b/packages/com.seaube.ecs-idl/Editor/EcsIdlPackagesPostprocessor.cs index 62bebc8..838fc64 100644 --- a/packages/com.seaube.ecs-idl/Editor/EcsIdlPackagesPostprocessor.cs +++ b/packages/com.seaube.ecs-idl/Editor/EcsIdlPackagesPostprocessor.cs @@ -54,7 +54,6 @@ static void OnPostprocessAllAssets } } - UnityEngine.Debug.Log("any packages update?!"); if(importedPkgs.Count > 0 || deletedPkgs.Count > 0 || movedPkgs.Count > 0) { RefreshEcsIdlCodegen(importedPkgs, deletedPkgs, movedPkgs); } @@ -117,9 +116,8 @@ static void RefreshEcsIdlCodegen Progress.Report(progressId, 0.1f); codegen.Start(); - UnityEngine.Debug.Log("getting plugins!"); foreach(var plugin in GetCodegenPlugins()) { - UnityEngine.Debug.Log("plugin!"); + // TODO: Custom codegen plugins } } @@ -135,11 +133,10 @@ static IEnumerable GetCodegenPlugins() { if(pluginAttrs.Length > 0) { var pluginAttr = pluginAttrs[0] as EcsIdlCodegenPluginAttribute; - UnityEngine.Debug.Log($"Plugin Name: {pluginAttr!.name}"); var plugin = System.Activator.CreateInstance(type) as EcsIdlCodegenPlugin; if(plugin == null) { - UnityEngine.Debug.Log( + UnityEngine.Debug.LogError( $"Invalid EcsIdlCodegenPlugin: {pluginAttr!.name}" ); } else { diff --git a/packages/com.seaube.ecs-idl/Editor/EcsIdlUnitySyncDebugWindow.cs b/packages/com.seaube.ecs-idl/Editor/EcsIdlUnitySyncDebugWindow.cs index fc8bca1..2f09c76 100644 --- a/packages/com.seaube.ecs-idl/Editor/EcsIdlUnitySyncDebugWindow.cs +++ b/packages/com.seaube.ecs-idl/Editor/EcsIdlUnitySyncDebugWindow.cs @@ -110,7 +110,6 @@ IEnumerator Refresh() { cancelledRequested = true; return false; }); - UnityEngine.Debug.Log("Refresh()?"); try { foreach(var (pc, typeName) in RefreshTypes()) { @@ -241,6 +240,11 @@ void PreviewEntityGameObjectPoolRemove } void OnGUI() { + if(refreshing) { + EditorGUILayout.HelpBox(new GUIContent("Refreshing...")); + return; + } + scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); allMonoBehavioursFoldout = EditorGUILayout.BeginFoldoutHeaderGroup( allMonoBehavioursFoldout, diff --git a/packages/com.seaube.ecs-idl/Editor/Importer/EcsIdlImporter.cs b/packages/com.seaube.ecs-idl/Editor/Importer/EcsIdlImporter.cs index 0263c36..a59a3d3 100644 --- a/packages/com.seaube.ecs-idl/Editor/Importer/EcsIdlImporter.cs +++ b/packages/com.seaube.ecs-idl/Editor/Importer/EcsIdlImporter.cs @@ -29,9 +29,32 @@ public override void OnImportAsset(AssetImportContext ctx) { codegen.StartInfo.RedirectStandardOutput = true; codegen.StartInfo.UseShellExecute = false; + var pkgJsonStr = ""; + var errMessage = ""; + + codegen.ErrorDataReceived += (_, ev) => { + if(ev.Data != null) { + errMessage += ev.Data; + } + }; + + codegen.OutputDataReceived += (_, ev) => { + if(ev.Data != null) { + pkgJsonStr += ev.Data; + } + }; + try { codegen.Start(); - codegen.WaitForExit(); + codegen.BeginOutputReadLine(); + codegen.BeginErrorReadLine(); + if(!codegen.WaitForExit(10000)) { + ctx.LogImportError("ECS IDL Importer timed out"); + return; + } else { + // See documentation https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.waitforexit?view=net-6.0#system-diagnostics-process-waitforexit(system-int32) + codegen.WaitForExit(); + } } catch(System.Exception err) { ctx.LogImportError(err.Message); return; @@ -42,7 +65,6 @@ public override void OnImportAsset(AssetImportContext ctx) { return; } - var pkgJsonStr = codegen.StandardOutput.ReadToEnd(); var pkgJson = JsonUtility.FromJson(pkgJsonStr); var pkg = (EcsIdlPackage)ScriptableObject.CreateInstance( typeof(EcsIdlPackage)