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.
- ScriptableObject.OnDestroy is not called after Respouces.UnloadUnusedAssets
- UI stops rendering when WaterSurface's Caustics are enabled
- Black screen frame appears in the WebGL Player when the Unity loading screen is over
- Crash on WriteParticleLineVertex when the "Generate Lighting Data" property is enabled in the Particle System
- UI overlay becomes visible in ray-traced reflections when HDR Color output is enabled