finds.dev← search

// the find

keijiro/TextureUpdateExample

★ 203 · C · updated Jun 2021

An example showing how to update textures from a native plugin in Unity.

A minimal Unity native plugin example demonstrating the CustomTextureUpdate callback API, which lets C/C++ code write texture data on a render thread without the usual GPU sync stalls. It's aimed at Unity developers building native plugins that generate or stream pixel data (video decoders, procedural textures, camera feeds) and need a thread-safe way to push it into a Texture2D.

The Plasma.c example is short enough to read end-to-end in a few minutes and maps directly onto Unity's actual callback signatures, so it works as a copy-paste starting point rather than an abstraction to fight. Precompiled binaries are checked in for five platforms (Windows, macOS, Linux, iOS, Android), so you can verify the callback wiring works before touching a compiler. It correctly demonstrates the two-phase begin/end event pattern, including the malloc/free lifecycle for the texData buffer, which is the part people usually get wrong on the C side.

No CMakeLists or unified build script tying the five platform folders together — each has its own build.sh with no explanation of toolchain prerequisites, so getting from source to the checked-in binaries yourself is undocumented. There's no error handling shown for allocation failure or texture format mismatches, and the example assumes a fixed RGBA8 layout with no discussion of other texture formats. Last pushed in mid-2021, so it predates several Unity graphics API changes; nothing here confirms it still works against SRP/URP or current Unity LTS versions. It's a single-effect demo, not a library, so there's no reusable plugin skeleton to build on beyond copying the file directly.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →