使用默认格式根据特定于平台的功能从脚本创建纹理或 RenderTextures。
using UnityEngine; using UnityEngine.Experimental.Rendering; using System.Collections;
public class ExampleClass : MonoBehaviour { void Start() { // Create a new texture and assign it to the material of the renderer. Texture2D texture = new Texture2D(1, 1, DefaultFormat.LDR, TextureCreationFlags.None); GetComponent<Renderer>().material.mainTexture = texture; } }
每个图形卡可能并不支持跨格式的所有用法。使用 SystemInfo.IsFormatSupported to check which usages the graphics card supports. See Also: Texture2D, 纹理资源。