Unity-Technologies/NativeRenderingPlugin logo

Unity-Technologies/NativeRenderingPlugin

Free

C++ Rendering Plugin example for Unity

FreeFree tier
Type
Open Source
Company
Unity Technologies

About Unity-Technologies/NativeRenderingPlugin

This repository provides a C++ native code rendering plugin example for Unity, demonstrating how to render graphics and interact with Unity's rendering pipeline through the native plugin interface. The plugin showcases basic plumbing, drawing a colored rotating triangle, modifying Unity texture pixel data with an animated plasma pattern, and altering mesh vertex data with a heightfield animation. It supports a wide range of platforms and graphics APIs including Windows (D3D11, D3D12, OpenGL, Vulkan), macOS (Metal, OpenGL), Linux (OpenGL, Vulkan), UWP (D3D11, D3D12), WebGL (OpenGL ES), Android (OpenGL ES, Vulkan), iOS/tvOS (Metal), EmbeddedLinux (OpenGL, OpenGL ES, Vulkan), and QNX (OpenGL ES). The code is organized into PluginSource with project files for Visual Studio 2022, Xcode, GNUMake, and others, and a UnityProject containing a sample scene. Licensed under MIT.

Key Features

Demonstrates native plugin interface plumbing and graphics API initialization
Draws a colored rotating triangle
Modifies Unity texture pixel data with an animated plasma pattern via GetNativeTexturePtr
Modifies Unity mesh vertex data with heightfield animation via GetNativeVertexBufferPtr
Supports Windows, macOS, Linux, UWP, WebGL, Android, iOS/tvOS, EmbeddedLinux, QNX with multiple graphics APIs
Provides project files for Visual Studio, Xcode, GNUMake, and other IDEs
Open source with MIT license

Pros & Cons

Pros
  • Wide platform and graphics API support (D3D11/12, Metal, OpenGL, Vulkan, OpenGL ES)
  • Demonstrates multiple rendering techniques (drawing, texture manipulation, mesh vertex modification)
  • Well-organized code with separate source and project files
  • Official repository from Unity Technologies, actively maintained
  • MIT license allows unrestricted use and modification
Cons
  • Vulkan and D3D12 support requires manual enabling and additional SDK installation
  • Example is minimal and not production-ready
  • Default branch requires Unity 2023.1+
  • Documentation relies on external Unity Manual references

Best For

Learning native rendering plugin development for UnityPrototyping cross-platform graphics featuresReference for implementing custom rendering in Unity

FAQ

What license is this under?
The plugin is released under the MIT license.
Which Unity version is required?
The default branch works with Unity 2023.1 and newer.
How to enable Vulkan or D3D12 support?
Edit the #define SUPPORT_VULKAN and SUPPORT_D3D12 macros in PlatformBase.h to 1 and install the required SDKs (Vulkan SDK or D3D12 headers).