Search Unity

[CanEditMultipleObjects] + Custom Editor NOT working

Discussion in 'Editor & General Support' started by Xelnath, Dec 20, 2018.

  1. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    402
    I have a custom editor that can edit any Asset which is a child of class ArmourAsset

    ArmourAsset has 4 children, HelmAsset, ChestAsset, RingAsset, LegsAsset.

    The custom editor has Can edit multiple objects - but it ONLY runs the editor if I select multiple objects of the *same* asset type. My editor uses reflection to properly update the values of each ArmourAsset and doesn't care about the child type - but the editor refuses to display the custom inspector I've written.

    How do I fix this?
     
  2. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    402
    Example code:


    [CanEditMultipleObjects]
    [CustomEditor( typeof( ArmourDataAsset ), true, isFallback = false )]
    public class ArmourDataAssetEditor : UnityEditor.Editor
    {
    public override void OnInspectorGUI() {
    // Correctly handles multiple object types as long as they are armour data assets or their children.
    }
    }
    Why won't unity display the inspector? Instead it says 'Narrow the selection'. This is completely irritating.