Version: 2020.1

Texture.imageContentsHash

切换到手册
public Hash128 imageContentsHash ;

描述

纹理的哈希值。

哈希值是一个 128 位的数字,其计算方式会使稍微不同的纹理也具有不同的哈希值。在这种情况下,哈希的主要用途是检测纹理何时发生变化。在更改或渲染到纹理时,Unity 会更新哈希。同样,您必须在修改纹理内容时计算新哈希,以便 Unity 知道纹理是何时更改的。更改哈希可使全局光照系统知道它需要重新计算场景中受纹理影响的贴图。

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

Using the pixel values of the texture to calculate the hash might be inefficient or impossible. A more efficient way of doing this is to hash the input parameters of the code you used to create the Texture. Whatever method you use, you must ensure that the resulting hash is different for different textures, and the same for the identical textures.

See Also: Hash128.Compute.