[ExecuteAlways] doesn't always work

I’ve got two classes that are identical other than name and an irrelevant enum:

using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class SpeedometerNeedle : MonoBehaviour
{
    SpinnerType spinnerType = SpinnerType.SpeedometerNeedle;

    Spinner spinner = new Spinner();
    public SpinnerSpinAxis spinAxis = SpinnerSpinAxis.Z;
    public List<MeshFilter> meshFilters = new List<MeshFilter>();
    public NeedleParams needleParams = new NeedleParams();


    private void OnRenderObject()
    {
        if (needleParams.copyToTransform)
            needleParams.copyToTransform.rotation = transform.rotation;

        needleParams.WriteToSpinner(spinner, spinnerType, spinAxis, transform);
    }

}
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class TachometerNeedle : MonoBehaviour
{
    SpinnerType spinnerType = SpinnerType.TachometerNeedle;

    Spinner spinner = new Spinner();
    public SpinnerSpinAxis spinAxis = SpinnerSpinAxis.Z;
    public List<MeshFilter> meshFilters = new List<MeshFilter>();
    public NeedleParams needleParams = new NeedleParams();
 
    private void OnRenderObject()
    {
        if (needleParams.copyToTransform)
            needleParams.copyToTransform.rotation = transform.rotation;

        needleParams.WriteToSpinner(spinner, spinnerType, spinAxis, transform);
    }
}

These are tagged as [ExecuteAlways] but only one of them is working. If I stick a breakpoint in OnRenderObject() on both classes, the SpeedometerNeedle one gets hit but the TachometerNeedle one doesn’t. It worked yesterday, but not today. This was a problem in 2020 version so I updated to 2022.1.10f1, but it still doesn’t work.

Why?

1 Like

At all? Or just not continuously?

If you look at ExecuteAlways docs, it specifically says that method only gets called when the Scene or Game windows gets a paint message.

https://docs.unity3d.com/ScriptReference/ExecuteAlways.html

At all. One always works, the other never does. Yesterday they both worked fine.

1 Like