Search Issue Tracker
Fixed in 2021.2.X
Planned for 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.
- [iOS] Crash on ScriptingGCHandle::Acquire when calling RequestUserAuthorization without using yield for pending authorization
- Particle is not visible in RenderTexture when Renderer's material is set to Default-Particle and Camera's BG Alpha is set 0
- OnTriggerExit is not called when GameObject leaves Trigger through reparenting
- [Physics] Character Joint jumps around when following Kinetic Rigidbody
- [macOS] There is no way to tell if you are running under Rosetta