Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug [ExecuteAlways] doesn't always work

Discussion in 'Editor & General Support' started by Todd-Wasson, Jul 22, 2022.

  1. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,077
    I've got two classes that are identical other than name and an irrelevant enum:


    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. [ExecuteAlways]
    4. public class SpeedometerNeedle : MonoBehaviour
    5. {
    6.     SpinnerType spinnerType = SpinnerType.SpeedometerNeedle;
    7.  
    8.     Spinner spinner = new Spinner();
    9.     public SpinnerSpinAxis spinAxis = SpinnerSpinAxis.Z;
    10.     public List<MeshFilter> meshFilters = new List<MeshFilter>();
    11.     public NeedleParams needleParams = new NeedleParams();
    12.  
    13.  
    14.     private void OnRenderObject()
    15.     {
    16.         if (needleParams.copyToTransform)
    17.             needleParams.copyToTransform.rotation = transform.rotation;
    18.  
    19.         needleParams.WriteToSpinner(spinner, spinnerType, spinAxis, transform);
    20.     }
    21.  
    22. }

    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. [ExecuteAlways]
    4. public class TachometerNeedle : MonoBehaviour
    5. {
    6.     SpinnerType spinnerType = SpinnerType.TachometerNeedle;
    7.  
    8.     Spinner spinner = new Spinner();
    9.     public SpinnerSpinAxis spinAxis = SpinnerSpinAxis.Z;
    10.     public List<MeshFilter> meshFilters = new List<MeshFilter>();
    11.     public NeedleParams needleParams = new NeedleParams();
    12.  
    13.     private void OnRenderObject()
    14.     {
    15.         if (needleParams.copyToTransform)
    16.             needleParams.copyToTransform.rotation = transform.rotation;
    17.  
    18.         needleParams.WriteToSpinner(spinner, spinnerType, spinAxis, transform);
    19.     }
    20. }
    21.  
    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?
     
    Last edited: Jul 22, 2022
    trombonaut likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,122
  3. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,077
    At all. One always works, the other never does. Yesterday they both worked fine.
     
    trombonaut likes this.