PropertyIDToName(int)
Returns the name of the shader property from its ID, or null string if the ID is invalid.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static string PropertyIDToName(int id)
Parameters
Returns
Type | Description |
|---|---|
| string | The property name corresponding to the given ID, or a null string if the ID is invalid. |
Remarks
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.
Examples
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"; }}