| Parameter | Description |
|---|---|
| propertyID | The ID of the shader property to get the name of. Use Shader.PropertyToID to get an ID. |
void The property name corresponding to the given ID, or a null string if the ID is invalid.
Returns the name of the shader property from its ID, or null string if the ID is invalid.
This method allows you to get the original property name using the ID of a shader property. Use the name only for debugging and introspection, because passing strings is slower than passing property IDs.
Property IDs that were not created with Shader.PropertyToID are considered invalid.
Compared to Shader.TryConvertPropertyIDToName, this method returns a null string in the situation where the property ID is invalid.
Check for null or an empty string to determine whether the ID was valid.
Additional resources: Shader.TryConvertPropertyIDToName, Shader.PropertyToID.
using UnityEngine;
public class PropertyIDToNameExample : MonoBehaviour { private void Start() { int propertyID = Shader.PropertyToID("_MainTex"); Debug.Log(Shader.PropertyIDToName(propertyID)); // prints "_MainTex"
int invalidId = 999999; Debug.Log(Shader.PropertyIDToName(invalidId)); // prints "null"; } }