Search Issue Tracker
Fixed in 2021.2.X
Fixed in 2020.3.X, 2021.1.X
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:
class MixtureInspectorTexture2D : MixtureEditor
public override bool HasPreviewGUI() => true;
- 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.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Incorrect Burst Exception Control Flow in Editor due to Mono Handling of calli instruction
- [Linux] Packman options to add package from Git URL doesn't always show the window directly below the + button
- "UnityEngine.SystemInfo.processorFrequency" logs a value of 0 on M1 macs
- Editor redirects to a broken page when pressing question mark "?" in the Inspector window
- Editor directs to non-existent page when pressing "Learn more..." for Asset Pipeline