public static void OnNeedsPaint(HTML_NeedsPaint_t pParam) { Console.WriteLine("Browser needs painting."); if (pParam.unWide != Width) { Console.WriteLine("bad texture width for html\n"); return; } if (pParam.unTall != Height) { Console.WriteLine("bad texture height for html\n"); return; } Marshal.Copy(pParam.pBGRA, pixels, 0, pixels.Length); for (int i = 0; i < pixels.Length; i += 4) { Game.CoreMath.Swap(ref pixels[i], ref pixels[i + 2]); if (pixels[i] == 0 && pixels[i + 1] == 0 && pixels[i + 2] == 0) { pixels[i + 3] = 0; } } Texture.SetData(pixels); }
void OnHTML_NeedsPaint(HTML_NeedsPaint_t pCallback) { Debug.Log("[" + HTML_NeedsPaint_t.k_iCallback + " - HTML_NeedsPaint] - " + pCallback.unBrowserHandle + " -- " + pCallback.pBGRA + " -- " + pCallback.unWide + " -- " + pCallback.unTall + " -- " + pCallback.unUpdateX + " -- " + pCallback.unUpdateY + " -- " + pCallback.unUpdateWide + " -- " + pCallback.unUpdateTall + " -- " + pCallback.unScrollX + " -- " + pCallback.unScrollY + " -- " + pCallback.flPageScale + " -- " + pCallback.unPageSerial); if (m_Texture == null) { m_Texture = new Texture2D((int)pCallback.unWide, (int)pCallback.unTall, TextureFormat.BGRA32, false, true); } int dataSize = (int)(pCallback.unWide * pCallback.unTall * 4); byte[] bytes = new byte[dataSize]; System.Runtime.InteropServices.Marshal.Copy(pCallback.pBGRA, bytes, 0, dataSize); m_Texture.LoadRawTextureData(bytes); m_Texture.Apply(); }