Search Unity

UnityEditor.EditorApplication.update called only once

Discussion in 'Scripting' started by Guedez, Sep 20, 2017.

  1. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    Exactly as the title says
    This is the code:
    Code (csharp):
    1. #if UNITY_EDITOR
    2.     [ExecuteInEditMode, UnityEditor.InitializeOnLoad]
    3. #endif
    4.     public class GrassTile : MonoBehaviour, ISerializationCallbackReceiver {
    5.  
    6. #if UNITY_EDITOR
    7.         public static void EditorUpdate() {
    8.             Debug.Log("EditorUpdate");
    9.         }
    10.         static GrassTile() {
    11.             UnityEditor.EditorApplication.update += EditorUpdate;
    12.             Debug.Log("GrassTile");
    13.         }
    14. #endif
    15.     }
    this is the console output:
    Code (csharp):
    1. GrassTile                                                                            (1)
    2. EditorUpdate                                                                         (1)
    What did I do wrong? It should be spamming my console with "EditorUpdate" but it's not
    As a workaround I am using
    Code (csharp):
    1.         public static void EditorUpdate() {
    2.             Debug.Log("EditorUpdate");
    3.             UnityEditor.EditorApplication.delayCall += EditorUpdate;
    4.         }
    But I'd rather do it the 'right way'
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175