TextureUpdater icon indicating copy to clipboard operation
TextureUpdater copied to clipboard

Update textures at runtime in Unity

TextureUpdater

Texture Updater uses CommandBuffer.IssuePluginCustomTextureUpdate to update the texture at runtime. In addition, the generated texture image is done in C# with the help of the job system and the burst compiler.

The Plasma effect example is ported from https://github.com/keijiro/TextureUpdateExample/

Why?

CommandBuffer.IssuePluginCustomTextureUpdate is designed to work with native code, but any change of the logic requires recompiling the plugins for each platform. This approach makes the texture updater plugin reusable, as the texture update logic is moved to C#.

known issues

  • Because the native thread is calling managed code (to generate the texture), it is causing the editor to hang on domain unload (the second time you press play). The example is currently using Texture2D.LoadRawTextureData in the editor to prevent this issue.