Unity 6.3
0 онлайн 56 гостей 3 в системе
Вход

GraphicsTexture.active

Declaration

public static Rendering.GraphicsTexture active;

Описание

Текущая активная графическая текстура.

Все рендеринг идет в активный GraphicsTexture. Если активный GraphicsTexture является null, все отображается в главном окне. Если активным объектом отображения RenderTexture, GraphicsTexture.active возвращает graphicsTexture от RenderTexture.active.

Чтобы установить активную цель отображения на GraphicsTexture, он должен иметь GraphicsTextureDescriptorFlags.RenderTarget включено в GraphicsTextureDescriptor.flags на создание текстуры.

Настройка GraphicsTexture.active это то же самое, что и вызов Graphics.SetRenderTarget с одним GraphicsTexture. Обычно вы меняете или запрашиваете активную цель рендеринга при реализации пользовательских графических эффектов; если все, что вам нужно, это сделать Camera рендеринг в текстуру, затем использование Camera.targetTexture с RenderTexture вместо этого.

Дополнительные ресурсы: GraphicsTextureDescriptorFlags.RenderTarget, Graphics.SetRenderTarget, RenderTexture.active.

using UnityEngine;
using UnityEngine.Rendering;
using System.Collections;

// Get the contents of a GraphicsTexture into a Texture2D public class ExampleClass : MonoBehaviour { static public Texture2D GetGfxTexPixels(GraphicsTexture gfxTex) { // Remember currently active render target GraphicsTexture currentActiveRT = GraphicsTexture.active;

// Set the supplied GraphicsTexture as the active one GraphicsTexture.active = gfxTex;

// Create a new Texture2D and read the GraphicsTexture image into it Texture2D tex = new Texture2D(gfxTex.descriptor.width, gfxTex.descriptor.height); tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0); tex.Apply();

// Restore previously active render texture GraphicsTexture.active = currentActiveRT; return tex; } }