Skip to content

Commit

Permalink
Removed some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Jan 10, 2022
1 parent 953be5a commit 83cfc8c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
}
}

Expand All @@ -135,11 +133,10 @@ static IEnumerable<EcsIdlCodegenPlugin> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ IEnumerator<string> Refresh() {
cancelledRequested = true;
return false;
});
UnityEngine.Debug.Log("Refresh()?");

try {
foreach(var (pc, typeName) in RefreshTypes()) {
Expand Down Expand Up @@ -241,6 +240,11 @@ void PreviewEntityGameObjectPoolRemove
}

void OnGUI() {
if(refreshing) {
EditorGUILayout.HelpBox(new GUIContent("Refreshing..."));
return;
}

scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
allMonoBehavioursFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(
allMonoBehavioursFoldout,
Expand Down
26 changes: 24 additions & 2 deletions packages/com.seaube.ecs-idl/Editor/Importer/EcsIdlImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,7 +65,6 @@ public override void OnImportAsset(AssetImportContext ctx) {
return;
}

var pkgJsonStr = codegen.StandardOutput.ReadToEnd();
var pkgJson = JsonUtility.FromJson<PkgInfoJson>(pkgJsonStr);
var pkg = (EcsIdlPackage)ScriptableObject.CreateInstance(
typeof(EcsIdlPackage)
Expand Down

0 comments on commit 83cfc8c

Please sign in to comment.