Search Unity

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:
    116
    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:
    78
    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:
    116
  4. sp-LeventeLajtai

    sp-LeventeLajtai

    Joined:
    Jul 11, 2019
    Posts:
    10
    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
  5. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,349
    I have an asset that paints on scene, sometimes wont paint because seemingly the scene or inspector is not updated, could it be a similar to this bug issue ?

    Thanks