|
|
|
@ -2,6 +2,7 @@ using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using System.Text; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
public class UniQuake: MonoBehaviour |
|
|
|
@ -35,8 +36,12 @@ public class UniQuake: MonoBehaviour |
|
|
|
/// </summary>
|
|
|
|
public double CurrentTime => Time.timeAsDouble - startTime; |
|
|
|
|
|
|
|
private Action<string> logHandler; |
|
|
|
|
|
|
|
void Start() |
|
|
|
{ |
|
|
|
logHandler = PrintLog; // Send each log statement to Unity immediately during startup
|
|
|
|
|
|
|
|
systemModule = new SystemModule(this); |
|
|
|
renderModule = new RenderModule(this); |
|
|
|
|
|
|
|
@ -109,6 +114,8 @@ public class UniQuake: MonoBehaviour |
|
|
|
if (!initialized) |
|
|
|
return; |
|
|
|
|
|
|
|
logHandler = CollectLog; // Collect and dump logs to Unity once per frame
|
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
UniQuake_Update(Time.deltaTime); |
|
|
|
@ -127,6 +134,8 @@ public class UniQuake: MonoBehaviour |
|
|
|
Debug.LogException(ex); |
|
|
|
Shutdown(); |
|
|
|
} |
|
|
|
|
|
|
|
FlushLog(); |
|
|
|
} |
|
|
|
|
|
|
|
private void Shutdown() |
|
|
|
@ -150,6 +159,32 @@ public class UniQuake: MonoBehaviour |
|
|
|
FreeLibrary(); |
|
|
|
} |
|
|
|
|
|
|
|
public void AddLog(string log) |
|
|
|
{ |
|
|
|
logHandler?.Invoke(log); |
|
|
|
} |
|
|
|
|
|
|
|
private void PrintLog(string log) |
|
|
|
{ |
|
|
|
Debug.Log(log); |
|
|
|
} |
|
|
|
|
|
|
|
private StringBuilder logBuffer = new StringBuilder(); |
|
|
|
|
|
|
|
private void CollectLog(string log) |
|
|
|
{ |
|
|
|
logBuffer.Append(log); |
|
|
|
} |
|
|
|
|
|
|
|
private void FlushLog() |
|
|
|
{ |
|
|
|
if (logBuffer.Length > 0) |
|
|
|
{ |
|
|
|
Debug.Log(logBuffer.ToString()); |
|
|
|
logBuffer.Clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
|
|
|
private delegate void UniQuake_InitFunc(IntPtr parms, IntPtr sysCalls, IntPtr glCalls); |
|
|
|
private UniQuake_InitFunc UniQuake_Init; |
|
|
|
|