Hey everyone, I’m still learning Unity and I’m specifically trying to figure out custom inspectors using a random test project and some pokemon sprites I just happened to have to figure out some 2D Development. I wrote a quick custom inspector for Sprites based on a tutorial I saw:
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Sprite))]
public class InspectorTest : Editor {
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
Sprite sprite = (Sprite)target;
if (GUILayout.Button("Test GUI"))
{
Debug.Log("Hello World!");
}
}
}
The logic works, but I noticed something really weird. The preview image(s) that are normally on the assets at the bottom right (the black box) seem to go away (it replaces as asset labels instead with nothing in it), the preview image in the inspector on the top left disappears, and the icons for the sprites in the asset folder explorer seems to turn into a blue box, as seen here (left is before the inspector was added, right is after it was added):
I think this might be happening because I need to reintroduce the ability to preview assets in the custom inspector since I’m overwriting the default one? But I’m not sure, I can’t seem to find what I’m looking for exactly with google, so thought I would ask here.
I tried refreshing the assets and I also tried reimporting, but neither seemed to have fixed the problem.