Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

OnInspectorGUI not being called on DefaultAsset in 2019.2.0f1

Discussion in 'Scripting' started by highlyinteractive, Aug 8, 2019.

  1. highlyinteractive

    highlyinteractive

    Joined:
    Sep 6, 2012
    Posts:
    94
    This code works fine in 2019.1 but OnInspectorGUI is no longer called in 2019.2

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3.  
    4. [CustomEditor(typeof(DefaultAsset))]
    5. public class AssetPreview : Editor
    6. {
    7.     private void OnEnable ()
    8.     {
    9.         string path = AssetDatabase.GetAssetPath(target);
    10.         Debug.Log("You have selected: " + path);
    11.     }
    12.  
    13.     public override void OnInspectorGUI ()
    14.     {
    15.         Debug.Log("This should be called when any default asset is selected");
    16.  
    17.         base.OnInspectorGUI();
    18.     }
    19. }
    20.  
    I've submitted a bug report (1175246), but just wanted to know if anyone else has found this, or if something in Unity has been changed that I should be aware of.
     
    Last edited: Aug 8, 2019
  2. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    35
    Same problem here. My custom TextAsset editor stopped working. OnEnable, OnDisable, OnHeaderGUI are called, but not OnInspectorGUI
     
  3. highlyinteractive

    highlyinteractive

    Joined:
    Sep 6, 2012
    Posts:
    94
  4. sp-LeventeLajtai

    sp-LeventeLajtai

    Joined:
    Jul 11, 2019
    Posts:
    6
    Is there some kind of workaround for this? Forcing a call to
    OnInspectorGUI()
    somehow? I tried calling it from
    OnHeaderGUI()
    as GamerXP says it works, and it does do something, but other errors are thrown...

    Edit:
    I've just realised that the errors came due to another reason. Adding an
    override OnHeaderGUI()
    and calling
    OnInspectorGUI()
    from there is workaround for the Unity bug.
     
    Last edited: Oct 30, 2019
unityunity