/// <summary>
/// Sends render commands to native code
/// </summary>
public static void RenderOnscreen(Noesis.View view, bool flipY, UnityEngine.Rendering.CommandBuffer commands)
{
// This is a workaround for a bug in Unity. When rendering nothing Unity sends us an empty MTLRenderCommandEncoder
if (UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal)
{
if (_dummyMesh == null)
{
_dummyMesh = new UnityEngine.Mesh();
_dummyMesh.vertices = new UnityEngine.Vector3[3];
_dummyMesh.vertices[0] = new UnityEngine.Vector3(0, 0, 0);
_dummyMesh.vertices[1] = new UnityEngine.Vector3(0, 0, 0);
_dummyMesh.vertices[2] = new UnityEngine.Vector3(0, 0, 0);
_dummyMesh.triangles = new int[3] {
0, 2, 1
};
}
if (_dummyMaterial == null)
{
_dummyMaterial = new UnityEngine.Material(UnityEngine.Shader.Find("UI/Default"));
}
commands.DrawMesh(_dummyMesh, new UnityEngine.Matrix4x4(), _dummyMaterial);
}
commands.IssuePluginEventAndData(_renderOnscreenCallback, flipY ? 1 : 0, view.CPtr.Handle);
}