I have a custom file extension “myExt” and import files of that type via a ScriptedImporter. In the Unity project window, these files are displayes as blank white icons. Can I somehow assign a new icon for my custom file type?
So I’ve spent some time experimenting and found:
- If I assign an icon to the ScriptedImporter class in the inspector or its editor class or place a file named “MyScriptedImporter Icon.png” in the Gizmos folder, the importer script itself stores the icon as it would work with MonoBehaviour classes. However, this icon does not show on the imported asset of my custom file type.
- If I add any UnityEngine.Object sub-assets to my imported asset, I can manually load and pass an icon file. However, this is slightly weird, since in my case, for example, I don’t actually have any objects creates, its just a text file and when I add the icon as a Texture2D object, the imported asset is treated like a texture (Texture2D icon showing) which is not what I want.
- I tried rendering a static preview via the ScriptedImporterEditor, but the callback was simply never invoked. I’ve previously used this on regular custom editor code applied to ScriptableObject assets where it worked, but with ScriptedImporter it might be not implemented or I’m missing something else. The editor also has a flag for useAssetDrawPreview which I set to false and HasPreviewGUI set to true, but the DrawPreview callback was not invoked.
So it looks as if there is currently no way of simply assigning an icon for a custom file without any workarounds.
Bump, I have exactly the same issue and I’ve tried the exact same steps.
Why is RenderStaticPreview never called on ScriptedImporterEditor?