Version: 2023.1
public bool Create ();

返回

bool 如果创建了纹理,则为 true,否则为 false。

描述

实际创建 RenderTexture。

实际上,RenderTexture 构造函数并不创建硬件纹理; 默认情况下,纹理在第一次被设置为 active 时创建。 调用 Create 可以事先创建纹理。 如果纹理已创建,Create 不执行任何操作。

The initial contents of a newly created render texture are undefined. On some platforms and APIs the contents will default to black, but you shouldn't depend on this. You can use LoadStoreActionDebugModeSettings to highlight undefined areas of the display, to help you debug rendering problems on mobile platforms.

另请参阅:ReleaseIsCreated 函数。

using UnityEngine;

public class Example : MonoBehaviour { public RenderTexture rt;

void Start() { rt = new RenderTexture(256, 256, 16, RenderTextureFormat.ARGB32); rt.Create();

// Add code here to work on the render texture

// Release the hardware resources used by the render texture rt.Release(); } }