Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 998 Bytes

File metadata and controls

53 lines (42 loc) · 998 Bytes

UEA0007: DoNotUseForEachInUpdate

Property Value
Id UEA0007
Category Performance
Severity Warning
Versions affected 1.0 - 5.5

Example

Code with Diagnostic

using UnityEngine;

class ExampleC : MonoBehaviour
{
    void Update()
    {
            var colors = new[] {""red"", ""white"", ""blue""};
            var result = string.Empty;
            foreach (var color in colors)
            {
                result += color;
            }
        }
}

Code with Fix

using UnityEngine;

class ExampleC : MonoBehaviour
{
    void Update()
    {
            var colors = new[] {""red"", ""white"", ""blue""};
            var result = string.Empty;
            for (int i = 0; i < colors.length; i++)
            {
                result += colors[i];
            }
        }
}

See also

https://forum.unity.com/threads/upgraded-c-compiler-on-5-3-5p8.417363/#n21