ShaderVariantCollection
class in UnityEngine
/
Inherits from:Object
/
Implemented in:UnityEngine.CoreModule
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.
Properties 属性
| isWarmedUp | Is this ShaderVariantCollection already warmed up? (Read Only) | ||
| shaderCount | Number of shaders in this collection (Read Only). | ||
| variantCount | Number of total varians in this collection (Read Only). |
Constructors
| ShaderVariantCollection | Create a new empty shader variant collection. |
Public Methods 公共方法
| Add | Adds a new shader variant to the collection. | ||
| Clear | Remove all shader variants from the collection. | ||
| Contains | Checks if a shader variant is in the collection. | ||
| Remove | Adds shader variant from the collection. | ||
| WarmUp | Fully load shaders in ShaderVariantCollection. |
Inherited Members 继承成员
Properties 属性
| hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? | ||
| name | The name of the object. |
Public Methods 公共方法
| GetInstanceID | Returns the instance id of the object. | ||
| ToString | Returns the name of the object. |
Static Methods 静态方法
| Destroy | Removes a GameObject, component or asset. | ||
| DestroyImmediate | Destroys the object obj immediately. You are strongly recommended to use Destroy instead. | ||
| DontDestroyOnLoad | Do not destroy the target Object when loading a new Scene. | ||
| FindObjectOfType | Returns the first active loaded object of Type type. | ||
| FindObjectsOfType | Returns a list of all active loaded objects of Type type. | ||
| Instantiate | Clones the object original and returns the clone. |
Operators 运算符
| bool | Does the object exist? | ||
| operator != | Compares if two objects refer to a different object. | ||
| operator == | Compares two object references to see if they refer to the same object. |