You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
57 lines
1.3 KiB
using System;
|
|
using System.Runtime.InteropServices;
|
|
using UnityEngine;
|
|
|
|
public class UniQuake: MonoBehaviour
|
|
{
|
|
private const string DllName = "uniquake.dll";
|
|
private const int MemSize = 0x4000000; // 64 MB of heap space
|
|
|
|
private QuakeParms quakeParms;
|
|
private SysCalls sysCalls;
|
|
|
|
void Start()
|
|
{
|
|
string[] arguments =
|
|
{
|
|
"",
|
|
"-window",
|
|
"-width", "1440",
|
|
"-height", "1080",
|
|
};
|
|
|
|
quakeParms = new QuakeParms
|
|
{
|
|
baseDir = Application.persistentDataPath,
|
|
cacheDir = null,
|
|
};
|
|
quakeParms.SetArguments(arguments);
|
|
quakeParms.AllocateMemory(MemSize);
|
|
|
|
sysCalls = new SysCalls(this);
|
|
|
|
UniQuake_Init(quakeParms, sysCalls.ToIntPtr);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
UniQuake_Update(Time.deltaTime);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
sysCalls.Destroy();
|
|
|
|
if (quakeParms != null)
|
|
{
|
|
quakeParms.Destroy();
|
|
quakeParms = null;
|
|
}
|
|
}
|
|
|
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
|
private static extern void UniQuake_Init(QuakeParms parms, IntPtr syscalls);
|
|
|
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
|
private static extern void UniQuake_Update(float deltaTime);
|
|
}
|