mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user