PropertyToID(string)
Gets unique identifier for a shader property name.
Read time 1 minuteLast updated 9 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static int PropertyToID(string name)
Parameters
Shader property name.
Returns
Type | Description |
|---|---|
| int | Unique integer for the name. |
Remarks
Using property identifiers is more efficient than passing strings to all material property functions. For example if you are calling Material.SetColor a lot, or using MaterialPropertyBlock, then it is better to get the identifiers of the properties you need just once.
Each name of shader property (for example, or ) is assigned an unique integer number in Unity, that stays the same for the whole game. The numbers will not be the same between different runs of the game or between machines, so do not store them or send them over network.
_MainTex_ColorAdditional Resources: Material, MaterialPropertyBlock.