Search Issue Tracker

Fixed in 2021.2.X

Fixed in 2020.3.X, 2021.1.X



Found in


Issue ID




Texture Importer Inspector throws errors when a built-in texture inspector is overwritten in C#



When a custom inspector targetting Texture2D, Cubemap or Texture3D is present in the project, the texture importer inspector of these assets throws errors when they are displayed in the inspector window.

Stacktrace of the error:
InvalidCastException: Specified cast is not valid.
UnityEditor.TextureImporterInspector.get_textureInspector () (at <280242b5f32c446482b2e1fcdf7e6d80>:0)
UnityEditor.TextureImporterInspector.DrawPreview (UnityEngine.Rect previewArea) (at <280242b5f32c446482b2e1fcdf7e6d80>:0)
UnityEditor.PropertyEditor.DrawPreviewAndLabels () (at <280242b5f32c446482b2e1fcdf7e6d80>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <b50b24924f4d442fb2face92883f4dc2>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Here's an example of custom editor that causes the error:
[CustomEditor(typeof(Texture2D), false)]
class MixtureInspectorTexture2D : MixtureEditor
public override bool HasPreviewGUI() => true;

Repro steps:
- Download the repro project
- Select the texture A in the Assets folder
- Observe errors in the console, like in the attached gif.

Note that the issue doesn't repro on 2020.2. Tested on Unity 2021.1 and 2021.2.

Comments (10)

  1. aricjoshua

    Nov 24, 2021 04:46

  2. unity_8p6oRXXqiWbRTQ

    Jul 24, 2021 08:06

    THis is not fixed at all, getting this error in 2020.3.13f1

  3. nehvaleem

    Jul 22, 2021 08:50

    Come on, guys. LTS having the lowest priority. Bug reported in February. Still. Not. Fixed.

    Could you explain what the LTS means then? Because I am surely misinterpreting this.

  4. gonenb_unity

    Jul 19, 2021 10:11

    Not fixed, please reopen

  5. iamarugin

    Jul 17, 2021 08:51

    5 months have passed and still no fix for the UNITY LTS VERSION.

  6. io-games

    Jul 13, 2021 06:37

    Sorry, for prev comment. It's because Substance.Editor.TextureInspector can not cast

  7. io-games

    Jul 13, 2021 06:31

    Not usable editor for art team at all.

  8. Hyperg

    Jul 12, 2021 08:20

    This issue is currently present in 2020.3.12f1 and 2020.3.13f1 and the art team cannot basically use the editor in its current state. Please bump up the importance of this issue before applying the "LTS" status to these builds...

  9. daneobyrd

    Jun 23, 2021 17:13

    I am continuing to get this error even in 2020.3.12. Not being able to view textures in the inspector is becoming a real annoyance and should be a priority.

  10. futurlab_peterh

    Jun 07, 2021 15:16

    This issue got introduced somewhere between 2020.3.5f1 and 2020.3.9f1.

    On our project we're able to repro it on 2020.3.9f1, but not after downgrading back to 2020.3.4f1.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.