UEA0012: CameraMainIsSlow

October 2, 2019 ยท View on GitHub

PropertyValue
IdUEA0012
CategoryGC
SeverityWarning

Example

Code with Diagnostic

using UnityEngine;

class Example : MonoBehaviour
{
    void Update()
    {
        var orthographicSize = Camera.main.orthographicSize;
    }
}

Code with Fix

using UnityEngine;

class Example : MonoBehaviour
{
    Camera cachedCamera;

    void Start()
    {
        cachedCamera = Camera.main;
    }

    void Update()
    {
        var orthographicSize = cachedCamera.orthographicSize;
    }
}