This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口(API)参考
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Render

Gui to Texture#

This sample demonstrates how to render GUI elements into a texture using Gui.Render(). Instead of drawing directly to the screen, the GUI is redirected to a custom framebuffer, which isolates its rendering pipeline and allows the resulting texture to be applied to materials.

The GuiToTexture component supports two update modes:

  • In manual mode, the texture is updated only when explicitly calling RenderToTexture() method. This is used in the WidgetClock component, where the GUI (a digital clock) is re-rendered once per second, only when the displayed time changes.

  • Automatic mode is enabled by default and updates the GUI texture every frame. This is demonstrated in the WidgetNoSignal component, where a "No Signal" label moves across the screen like a screensaver. Because the position of the widget changes every frame, the texture must be continuously updated to reflect those changes.

The render flow involves saving and clearing the current render state, binding a texture, configuring the viewport, rendering the GUI widgets, and restoring the render state. Mipmaps are also generated to ensure proper filtering at different scales and distances.

You can use this sample to display dynamic GUI elements on in-game monitors, control panels, or other similar surfaces.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/render/gui_to_texture

Material Parameters#

Changing parameters of materials at runtime.

The Materials sample illustrates how to change the following parameters of materials in runtime:


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/render/material_parameters

Weapon Clipping#

In first-person games, weapon models can clip through walls or geometry when the camera gets too close. This sample solves the problem by rendering the weapon separately into a texture and overlaying it on top of the main camera view.

The setup uses two cameras with identical transforms to keep their views aligned. Viewport masks for cameras are set via UnigineEditor: the main camera renders everything except the weapon, while the secondary (weapon) camera renders only the weapon. The weapon view is captured into a texture using Viewport.RenderTexture2D().

Each frame, this texture is overlaid onto the screen using Render.RenderScreenMaterial(), compositing the weapon on top of the environment. The component handles screen resizing, maintains isolated render states, and offers optional settings like skipping shadows in the weapon rendering pass.

This approach keeps the weapon always visible, even when the camera is close to walls, without interfering with the main rendering pipeline


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/render/weapon_clipping

The information on this page is valid for UNIGINE 2.20 SDK.

Last update: 2025-06-30
Build: ()