Handle exceptions from C# Scripts + Log window + EditorLogger

+ Renamed Platform/DX11/ImGui.bf to .../Dx11ImGui.bf for clarity
+ ImGuiExtension: ImageButtonEx thata takes a TextureViewBinding
+ EditorLogger that logs to the LogWindow
+ Current logger can now be changed
+ Info, Trace, Warning and Error Icons
This commit is contained in:
Simon Lübeß
2023-07-27 21:58:42 +02:00
parent 0bc517842f
commit 1254d01545
17 changed files with 750 additions and 59 deletions
+29 -4
View File
@@ -209,12 +209,14 @@ static class ScriptEngine
if (scriptClass == null)
return false;
script.Instance = new ScriptInstance(scriptClass);
UUID entityId = entity.UUID;
script.Instance = new ScriptInstance(entityId, scriptClass);
script.Instance..ReleaseRef();
_entityScriptInstances[entity.UUID] = script.Instance..AddRef();
_entityScriptInstances[entityId] = script.Instance..AddRef();
script.Instance.Instantiate(entity.UUID);
script.Instance.Instantiate(entityId);
return true;
}
@@ -544,4 +546,27 @@ static class ScriptEngine
return scriptClass;
}
}
internal static void HandleMonoException(MonoException* exception, ScriptInstance sourceInstance = null)
{
MonoExceptionHelper wrappedException = new MonoExceptionHelper(exception);
String entityInfo = scope .();
if (sourceInstance != null)
{
wrappedException.Instance = sourceInstance.EntityId;
Result<Entity> sourceEntity = Context.GetEntityByID(sourceInstance.EntityId);
if (sourceEntity case .Ok(let e))
{
entityInfo.AppendF($" ({e.Name} | {sourceInstance.EntityId})");
}
}
Log.ClientLogger.Error($"Mono Exception \"{wrappedException.FullName}\": \"{wrappedException.Message}\"{entityInfo}\nStackTrace:\n{wrappedException.StackTrace}", wrappedException);
wrappedException.ReleaseRef();
}
}