private RenderTexture RenderPreview(Noesis.View view, int width, int height) { try { if (CanRender() && view != null && view.Content != null) { NoesisRenderer.SetRenderSettings(); view.SetSize(width, height); view.Update(0.0f); FlushMetalEncoder(_commands); NoesisRenderer.RenderOffscreen(view, _commands); RenderTexture rt = RenderTexture.GetTemporary(width, height, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 8); _commands.SetRenderTarget(rt); _commands.ClearRenderTarget(true, true, UnityEngine.Color.clear, 0.0f); NoesisRenderer.RenderOnscreen(view, false, _commands); Graphics.ExecuteCommandBuffer(_commands); _commands.Clear(); GL.InvalidateState(); RenderTexture.ReleaseTemporary(rt); return(rt); } } catch (System.Exception e) { UnityEngine.Debug.LogException(e); } return(null); }
private void CreateView(FrameworkElement content) { if (_uiView == null) { // Send settings for the internal device, created by the first view NoesisRenderer.SetRenderSettings(); _uiView = new Noesis.View(content); _uiView.SetTessellationMaxPixelError(_tessellationMaxPixelError); _uiView.SetFlags(_renderFlags); _commands.name = ""; NoesisRenderer.RegisterView(_uiView, _commands); Graphics.ExecuteCommandBuffer(_commands); _commands.Clear(); #if UNITY_EDITOR UnityEditor.AssemblyReloadEvents.beforeAssemblyReload += DestroyView; #endif } }