Texture.imageContentsHash

Switch to Manual
public Hash128 imageContentsHash ;

Description

纹理的哈希值。

The hash value is a 128-bit number computed in such a way that even slightly different textures have different hash values. The principal use of the hash in this case is to detect when the texture has changed. Unity updates the hash when changing or rendering into a texture. Likewise, you must calculate a new hash when modifying the texture contents so that Unity knows when the texture changes. Changing the hash lets the Global Illumination system know that it needs to recalculate maps in the Scene that are affected by the texture.

对于常规纹理,Unity 首先计算在将纹理导入 Editor 时的哈希,然后在光照和反射被“烘焙”到纹理后更新哈希。如果随后渲染到用作全局光照系统(例如天空、光照或反射探针)的输入的纹理,则您必须自行更新纹理哈希。注意,此哈希是只适用于 Editor 的属性。

注意,使用纹理的像素值计算哈希可能效率低或无法计算。您可以在创建纹理的代码中计算输入参数的哈希。重要的是,纹理不同则生成的哈希不同(相同的纹理对应相同的哈希)。