Skip to content

Latest commit

 

History

History
81 lines (63 loc) · 1.19 KB

File metadata and controls

81 lines (63 loc) · 1.19 KB

UEA0011: DoNotUseStringPropertyNames

Property Value
Id UEA0011
Category Performance
Severity Warning

Example

This is for both Material and Shader class methods. Both can be fixed by using Shader.PropertyToID() method.

Code with Diagnostic

class A : MonoBehaviour
{
    Shader shader;

    void Update()
    {
        shader.GetGlobalFloat("_Speed", 1f);
    }
}
class C : MonoBehaviour
{
    Material material;

    void Update()
    {
        material.SetVector("_WaveAndDistance", Vector3.one);
    }
}

Code with Fix

using UnityEngine;

class A : MonoBehaviour
{
    Shader shader;
    int speedHash;

    void Start() 
    {
        speedHash = Shader.PropertyToID("_Speed");
    }

    void Update()
    {
        shader.GetGlobalFloat(speedHash, 1f);
    }
}
using UnityEngine;

class C : MonoBehaviour
{
    Material material;
    int waveAndDistanceHash;

    void Start() 
    {
        waveAndDistanceHash = Shader.PropertyToID("_WaveAndDistance");
    }

    void Update()
    {
        material.SetVector(waveAndDistanceHash, Vector3.one);
    }
}