在 C# 代码中表示纹理的类。
使用该类可以创建纹理或修改现有的纹理资源。
ImageConversion 类可为此类提供用于处理图像编码功能的扩展方法。有关这些方法的详细信息,请参阅 ImageConversion 文档。
blackTexture | 获取一个全部为黑色像素的小纹理。 |
grayTexture | 获取一个全部为灰色像素的小纹理。 |
linearGrayTexture | 获取一个全部为灰色像素的小纹理。 |
normalTexture | 获取一个小纹理,其像素表示位于中立位置的表面法线矢量。 |
redTexture | 获取一个全部为红色像素的小纹理。 |
whiteTexture | 获取一个全部为白色像素的小纹理。 |
alphaIsTransparency | 指示是否在启用 TextureImporter.alphaIsTransparency 的情况下导入此纹理。此设置仅在编辑器脚本中可用。请注意,更改此设置将不起作用;必须在 TextureImporter 中启用它。 |
calculatedMipmapLevel | 串流系统计算的 Mipmap 级别,其中考虑了串流摄像机以及包含此纹理的对象的位置。它不受 requestedMipmapLevel 或 minimumMipmapLevel 影响。 |
desiredMipmapLevel | 应用内存预算之前由串流系统加载的 Mipmap 级别。 |
format | 纹理中像素数据的格式(只读)。 |
isReadable | 如果在导入纹理时选中了“Read/Write Enabled”复选框,则返回 true;否则返回 false。对于通过脚本创建的动态纹理,始终返回 true。有关更多信息,请参阅 TextureImporter.isReadable。 |
loadedMipmapLevel | 串流系统当前加载的 Mipmap 级别。 |
loadingMipmapLevel | Mipmap 串流系统正在加载的 Mipmap 级别。 |
minimumMipmapLevel | 将 Mipmap 串流系统限制为此纹理的最低 Mip 级别。 |
requestedMipmapLevel | 要加载的 Mipmap 级别。 |
streamingMipmaps | 确定是否已为纹理启用 Mipmap 串流。 |
streamingMipmapsPriority | 在减小内存大小以满足内存预算时设置纹理的相对优先级。 |
vtOnly | Returns true if the VTOnly checkbox was checked when the texture was imported; otherwise returns false. For additional information, see TextureImporter.vtOnly. |
Texture2D | 创建一个新的空纹理。 |
Apply | 实际应用任何先前的 SetPixel 和 SetPixels 更改。 |
ClearMinimumMipmapLevel | 重置 minimumMipmapLevel 字段。 |
ClearRequestedMipmapLevel | 重置 requestedMipmapLevel 字段。 |
Compress | 将纹理压缩为 DXT 格式。 |
GetPixel | 返回坐标 (x, y) 上的像素颜色。 |
GetPixelBilinear | 返回标准化坐标 (u, v) 处已过滤的像素颜色。 |
GetPixelData | Gets raw data from a Texture for reading or writing. |
GetPixels | 从纹理中获取像素颜色。 |
GetPixels32 | 获取像素颜色块(Color32 格式)。 |
GetRawTextureData | 从纹理中获取原始数据以进行读取或写入。 |
IsRequestedMipmapLevelLoaded | 检查通过 requestedMipmapLevel 设置的 Mipmap 级别是否已完成加载。 |
LoadRawTextureData | 使用原始预格式化数据填充纹理像素。 |
PackTextures | 将多个纹理打包到一个纹理图集中。 |
ReadPixels | 将屏幕像素读取到保存的纹理数据中。 |
Resize | 调整纹理大小。 |
SetPixel | 设置坐标 (x,y) 处的像素颜色。 |
SetPixelData | 用原始预格式化数据设置像素值。 |
SetPixels | 设置像素颜色块。 |
SetPixels32 | 设置像素颜色块。 |
UpdateExternalTexture | 更新 Unity 纹理以使用不同的原生纹理对象。 |
CreateExternalTexture | 基于外部创建的原生纹理对象创建一个 Unity 纹理。 |
GenerateAtlas | 将一组矩形打包成一个方形图集,并且可以选择在矩形之间进行填充。 |
allowThreadedTextureCreation | 允许在任何线程(而不是专用的渲染线程)中创建纹理。 |
currentTextureMemory | The amount of memory currently being used by the non-streaming and mipmap streaming textures combined. |
desiredTextureMemory | 在应用纹理串流预算之前会先使用上述的纹理内存量。 |
GenerateAllMips | 可与采用 Mip 数量的纹理构造函数结合使用,以指示应生成所有 Mip。此字段的值为 -1。 |
nonStreamingTextureCount | 非串流纹理的数量。 |
nonStreamingTextureMemory | 非串流纹理正在使用的内存总量。 |
streamingMipmapUploadCount | 由于纹理 Mipmap 串流而导致上传纹理的次数。 |
streamingRendererCount | 在纹理串流系统中注册的渲染器数量。 |
streamingTextureCount | 串流纹理的数量。 |
streamingTextureDiscardUnusedMips | 强制串流纹理系统立即丢弃所有未使用的 Mipmap,而不是缓存这些 Mipmap 直到超出纹理内存预算。 |
streamingTextureForceLoadAll | 强制串流纹理加载所有 Mipmap 级别。 |
streamingTextureLoadingCount | 当前正在加载 Mipmap 的串流纹理的数量。 |
streamingTexturePendingLoadCount | 要加载的未完成 Mipmap 的串流纹理数量。 |
targetTextureMemory | 应用 Mipmap 串流和预算并且在加载完成后由纹理使用的内存量。 |
totalTextureMemory | Mipmap 级别 0 的所有纹理将使用的内存总量。 |
hideFlags | 该对象应该隐藏、随场景一起保存还是由用户修改? |
name | 对象的名称。 |
anisoLevel | 纹理的各向异性过滤级别。 |
dimension | 纹理的维度(类型)(只读)。 |
filterMode | 纹理的过滤模式。 |
graphicsFormat | 返回纹理对象的 GraphicsFormat 格式或颜色格式。 |
height | 纹理的高度(以像素为单位)。(只读) |
imageContentsHash | 纹理的哈希值。 |
isReadable | 如果在导入纹理时选中了“Read/Write Enabled”复选框,则返回 true;否则返回 false。对于通过脚本创建的动态纹理,始终返回 true。有关更多信息,请参阅 TextureImporter.isReadable。 |
mipMapBias | The mipmap bias of the texture. |
mipmapCount | 该纹理中有多少个多级渐进纹理级别(只读)。 |
updateCount | 更新纹理时,此计数器会递增。 |
width | 纹理的宽度(以像素为单位)。(只读) |
wrapMode | 纹理坐标换行模式。 |
wrapModeU | 纹理 U 坐标换行模式。 |
wrapModeV | 纹理 V 坐标换行模式。 |
wrapModeW | Texture3D 的纹理 W 坐标换行模式。 |
GetInstanceID | 返回对象的实例 ID。 |
ToString | 返回对象的名称。 |
GetNativeTexturePtr | 获取指向纹理资源的原生(底层图形 API)指针。 |
IncrementUpdateCount | 递增更新计数器。 |
Destroy | 移除 GameObject、组件或资源。 |
DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
FindObjectOfType | 返回第一个类型为 type 的已加载的激活对象。 |
FindObjectsOfType | Gets a list of all loaded objects of Type type. |
Instantiate | 克隆 original 对象并返回克隆对象。 |
SetGlobalAnisotropicFilteringLimits | 设置各向异性限制。 |
SetStreamingTextureMaterialDebugProperties | Uploads additional debug information to materials using textures set to stream mipmaps. |
bool | 该对象是否存在? |
operator != | 比较两个对象是否引用不同的对象。 |
operator == | 比较两个对象引用,判断它们是否引用同一个对象。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.