一次加载所有Shader
一次性加载所有的Shader.避免材质上的Shader丢失,5.X需要调用
Shader.WarmupAllShaders
ShaderVariantCollection Document
Description
ShaderVariantCollection records which shader variants are actually used in each shader.
This is used for shader preloading (“warmup”), so that a game can make sure “actually required” shader variants are loaded at startup (or level load time), to avoid shader compilation related hiccups later on in the game.
In Unity, many shaders internally have multiple “variants”, to account for different light modes, lightmaps, shadows and so on. These variants are indentified by a shader pass type, and a set of shader keywords. See ShaderVariant.
Typical use of ShaderVariantCollection is to record the shader variants used during a play session from the editor (under Graphics Settings), save them out as an asset, and add to the list of preloaded shaders (again in Graphics Settings). Additionally, you could call WarmUp on a ShaderVariantCollection object manually.
ShaderVariantCollection generally replaces the old Shader.WarmupAllShaders function.
Note
对于Unity4.x版本,Shader的AssetBundle加载后只需LoadAll即可完成所有Shader的加载和解析,但对于Unity5.x版本,除执行LoadAllAssets操作外,还需要进行Shader.WarmupAllShaders操作,因为在Unity5.x版本中,Shader的解析和CreateGPUProgram操作是分离的。 – 摘录自UWA Unity加载模块深度解析(Shader篇)
参考文档
本文标题:一次加载所有Shader
文章作者:Keyle
发布时间:2017-01-09
最后更新:2024-08-20
原始链接:https://vrast.cn/posts/8cb143d1/
版权声明:©Keyle's Blog. 本站采用署名-非商业性使用-相同方式共享 4.0 国际进行许可